Advertisement
Guest User

Custom Menu System

a guest
Oct 23rd, 2017
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 129.72 KB | None | 0 0
  1. #==============================================================================
  2. # ** Custom Menu System
  3. #------------------------------------------------------------------------------
  4. # * Created by: albertfish
  5. # * Version: 1.0
  6. # * Last edited: September 5, 2009
  7. #------------------------------------------------------------------------------
  8. #  Description:
  9. #     This is a complete redesign of the default menu system redesigned for
  10. #     a 14 player party.
  11. #------------------------------------------------------------------------------
  12. #  Features:
  13. #     - Handles large parties
  14. #     - Allow to change the order of the members in the party
  15. #         - This is done via FOMAR1053 script
  16. #     - Handles character faces
  17. #         - Easy to set up
  18. #         - Easy to change during the game
  19. #     - Organized items menu system
  20. #         - Includes 9 different categories to sort items
  21. #         - Easy to set up items to be sorted
  22. #         - Easy to customize appearance
  23. #------------------------------------------------------------------------------
  24. #  Item Setup Instructions:
  25. #     This script sorts items automatically based on certain aspects of the
  26. #     item. To set up items to be sorted into correct categories follow this
  27. #     guide.
  28. #
  29. #     Consumable Items - Must have Consumable flag set to yes
  30. #                      - Must have Occasion flag set to anything other than
  31. #                        never.
  32. #     Weapons          - All items in Weapons tab in the database
  33. #     Body Equipment   - Must be under Armors tab
  34. #                      - Kind must be Body Armor
  35. #     Head Equipment   - Must be under Armors tab
  36. #                      - Kind must be Helmet
  37. #     Arm Equipment    - Must be under Armors tab
  38. #                      - Kind must be Shield
  39. #     Accessory        - Must be under Armors tab
  40. #                      - Kind must be Accessory
  41. #     Raw Materials    - Must be consumable
  42. #                      - Must have occasion of never
  43. #     Story Items      - Must be non consumable
  44. #------------------------------------------------------------------------------
  45. #  Face Setup Instructions:
  46. #     To set up faces for the actors, create a folder inside the Pictures
  47. #     folder and name if Faces. Inside this folder is where you place all of
  48. #     the faces. The initial face must have the same name as the actor.
  49. #     For example Aluxes' face graphic has the name Aluxes.
  50. #     During the game if you wish to change an actor's face graphic, execute
  51. #     this script command:
  52. #         $change_face.new("name", "image name")
  53. #     Where "name" is the name of the actor (eg. "Aluxes") and "image name" is
  54. #     the name of the face graphic you want (eg. "Aluxes2"). You must keep the
  55. #     quotation marks.
  56. #------------------------------------------------------------------------------
  57. #  Install Instructions:
  58. #     Place this script above the main script and below the default scripts.
  59. #==============================================================================
  60.  
  61. #==============================================================================
  62. # ** CMS_Config
  63. #------------------------------------------------------------------------------
  64. #  This module contains the configuration data of the menu.
  65. #------------------------------------------------------------------------------
  66. #  Begin Editable Area.
  67. #==============================================================================
  68.  
  69. module CMS_Config
  70.   # Main menu specific configuration
  71.   # these are specific only to Scene_Menu
  72.  
  73.   # Main menu icon/command setup
  74.   BG_MAP = true #make the map visible on the background
  75.   COMMAND_ITEM = "Items" #the name of the command item
  76.   COMMAND_SKILL = "Spells" #the name of the command skill
  77.   COMMAND_EQUIP = "Equip" #the name of the command equipment
  78.   COMMAND_STATUS = "Status" #the name of the command status
  79.   COMMAND_DATA = "Data" #name of logs command
  80.   COMMAND_SYSTEM = "System"
  81.   GOLD_ICON = "Gold" #the name of the gold icon
  82.   TIME_ICON = "clock" #the name of the time icon
  83.   MAP_ICON = "Hero" #the name of the map icon
  84.  
  85.    
  86.   # Main menu window setup
  87.   ANIMATION = true #enable the window animation
  88.   ICON = true #enable the icon in the command window
  89.   #Syntax: MENU_BGM = [name of the bgm, volume, pitch]
  90.   MENU_BGM = ["", 100, 100] #Change the music played during the menu
  91.  
  92.   COMMAND_WINDOW =  ["", 0, 0, 160, "Right"]
  93.   LOCATION_WINDOW = [true, 0, 416, 160, "Left", 224, 64, 24]
  94.   GOLD_WINDOW =     [true, 224, 416, 160, "Left", 192, 64, 24]
  95.   TIME_WINDOW =     [true, 416, 416, 160, "Up", 224, 64, 24]
  96.   STATUS_WINDOW =   [0, 64, 160, "Down"]
  97.   COMMAND_SETUP =   [COMMAND_ITEM, COMMAND_SKILL, COMMAND_EQUIP, COMMAND_STATUS, COMMAND_DATA, COMMAND_SYSTEM]
  98.  
  99.   # Set the menu item icons. These must be size 24px by 24px.
  100.   # The icons must be placed in the icons folder in the games directory
  101.   # and the file name of the icons must be placed between the quotation
  102.   # marks.  
  103.   ITEMS_MENU_ICONS = []
  104.   ITEMS_MENU_ICONS[0] = "032-Item01"  
  105.   ITEMS_MENU_ICONS[1] = "021-Potion01"  
  106.   ITEMS_MENU_ICONS[2] = "001-Weapon01"  
  107.   ITEMS_MENU_ICONS[3] = "013-Body01"  
  108.   ITEMS_MENU_ICONS[4] = "010-Head01"  
  109.   ITEMS_MENU_ICONS[5] = "009-Shield01"  
  110.   ITEMS_MENU_ICONS[6] = "017-Accessory02"  
  111.   ITEMS_MENU_ICONS[7] = "043-Item12"
  112.   ITEMS_MENU_ICONS[8] = "034-Item03"
  113.  
  114.   # Set the menu item text. This is the text that will display at the bottom
  115.   # informing the player what each category is.
  116.   ITEMS_MENU_TEXT = []
  117.   ITEMS_MENU_TEXT[0] = "Recent Items"  
  118.   ITEMS_MENU_TEXT[1] = "Potions"  
  119.   ITEMS_MENU_TEXT[2] = "Weapons"  
  120.   ITEMS_MENU_TEXT[3] = "Body Equipment"  
  121.   ITEMS_MENU_TEXT[4] = "Head Equipment"  
  122.   ITEMS_MENU_TEXT[5] = "Arm Equipment"  
  123.   ITEMS_MENU_TEXT[6] = "Accessories"  
  124.   ITEMS_MENU_TEXT[7] = "Raw Material"  
  125.   ITEMS_MENU_TEXT[8] = "Quest Items"  
  126.  
  127.   # Set up the status menu hp and sp bar images. The images must be 146px wide
  128.   # by 8px height.
  129.   # The images must be placed in the pictures folder in the games directory
  130.   # and the file name of the images must be placed between the quotation
  131.   # marks.
  132.   SM_BARBACK = "sm_barback"
  133.   SM_HPBAR = "sm_hpbar"
  134.   SM_SPBAR = "sm_spbar"
  135.  
  136.   # If true then the battler image will be double sized.
  137.   LARGE_BATTLER = true
  138.  
  139.   # Actory Element Icons. This is where you set which element icon will be
  140.   # displayed for each player. These must be size 24px by 24px.
  141.   ELEMENT_ICON = []
  142.   ELEMENT_ICON[0] = "fireicon" # First actor in the database
  143.   ELEMENT_ICON[1] = "fireicon" # Second actor in the database
  144.   ELEMENT_ICON[2] = "fireicon" # Third actor in the database
  145.   ELEMENT_ICON[3] = "fireicon" # Just keep adding these following
  146.   ELEMENT_ICON[4] = "fireicon" # the pattern for as many actors
  147.   ELEMENT_ICON[5] = "fireicon" # as you have in the database.
  148.   ELEMENT_ICON[6] = "fireicon" # Put "" for no icon.
  149.   ELEMENT_ICON[7] = "fireicon"
  150.   ELEMENT_ICON[8] = "fireicon"
  151.   ELEMENT_ICON[9] = "fireicon"
  152.   ELEMENT_ICON[10] = "fireicon"
  153.   ELEMENT_ICON[11] = "fireicon"
  154.   ELEMENT_ICON[12] = "fireicon"
  155.   ELEMENT_ICON[13] = "fireicon"
  156.   ELEMENT_ICON[14] = "fireicon"
  157.  
  158.   # Set the default font. The menu was designed with the settings:
  159.   #     Font.default_name = "Comic Sans MS"
  160.   #     Font.default_size = 24
  161.   # Changing the fonts may cause misalignments.
  162.   Font.default_name = "VL Gothic Regular"
  163.   Font.default_size = 24
  164. end
  165.  
  166. #==============================================================================
  167. #  End Editable Area.
  168. #------------------------------------------------------------------------------
  169. #  Warning! Do not edit beyond this point unless you know what you are doing!
  170. #==============================================================================
  171.  
  172. #==============================================================================
  173. # ** Window_Base
  174. #------------------------------------------------------------------------------
  175. #  This determines how some menu elements are drawn
  176. #==============================================================================
  177.  
  178. class Window_Base < Window
  179.   def draw_actor_face(actor, x, y)
  180.     bitmap = RPG::Cache.character("Face/"+actor.character_name, actor.character_hue)
  181.     cw = bitmap.width
  182.     ch = bitmap.height
  183.     src_rect = Rect.new(0, 0, cw, ch)
  184.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  185.   end
  186.   def draw_actor_exp(actor, x, y)
  187.     self.contents.draw_text(x - 2, y, 84, 32, "Next Lv", 2)
  188.     self.contents.draw_text(x + 82, y, 12, 32, ":", 1)
  189.     self.contents.draw_text(x + 94, y, 84, 32, actor.next_exp_s)
  190.   end
  191. end
  192.  
  193. #==============================================================================
  194. # ** Window_MenuStatus
  195. #------------------------------------------------------------------------------
  196. #  This window displays party member status on the menu screen.
  197. #==============================================================================
  198.  
  199. class Window_MenuStatus < Window_Selectable
  200.   #--------------------------------------------------------------------------
  201.   # * include the CMS_Config module
  202.   #--------------------------------------------------------------------------
  203.   include CMS_Config
  204.  
  205.   def initialize
  206.     super(STATUS_WINDOW[0], STATUS_WINDOW[1], 640, 352)
  207.     self.contents = Bitmap.new(width - 32, height - 32)
  208.     self.opacity = STATUS_WINDOW[2]
  209.     refresh
  210.     self.active = false
  211.     self.index = -1
  212.   end
  213.   def refresh
  214.     self.contents.clear
  215.     @column_max = 2
  216.     @item_max = $game_party.actors.size
  217.     for i in 0...$game_party.actors.size
  218.       if i == 0
  219.         x = 11
  220.         y = 11
  221.       elsif i == 1
  222.         x = 11
  223.         y = 171
  224.       elsif i == 2
  225.         x = 325
  226.         y = 11
  227.       elsif i == 3
  228.         x = 325
  229.         y = 171
  230.       end
  231.       actor = $game_party.actors[i]
  232.       draw_actor_face(actor, x + 45, y + 95)
  233.       draw_actor_name(actor, x + 15, y - 13)
  234.       draw_actor_level(actor, x + 15, y + 89)
  235.       draw_actor_state(actor, x, y + 114)
  236.       draw_actor_exp(actor, x + 110, y + 62)
  237.       draw_actor_hp(actor, x + 110, y + 6)
  238.       draw_actor_sp(actor, x + 110, y + 34)
  239.     end
  240.   end
  241.   def update_cursor_rect
  242.     if @index < 0
  243.       self.cursor_rect.empty
  244.     else
  245.     # Get current row
  246.     row = @index / @column_max
  247.     # If current row is before top row
  248.         if row < self.top_row
  249.         # Scroll so that current row becomes top row
  250.         self.top_row = row
  251.         end
  252.         # If current row is more to back than back row
  253.         if row > self.top_row + (self.page_row_max - 1)
  254.         # Scroll so that current row becomes back row
  255.         self.top_row = row - (self.page_row_max - 1)
  256.         end
  257.     # Calculate cursor width
  258.     cursor_width = self.width / @column_max - 16
  259.     # Calculate cursor coordinates
  260.     x = @index % @column_max * (cursor_width + 4)
  261.     y = @index / @column_max * 160 - self.oy
  262.     # Update cursor rectangle
  263.     self.cursor_rect.set(x, y, cursor_width, 164)
  264.     end
  265. end
  266. end
  267.  
  268. #==============================================================================
  269. # ** Window_MenuCommand
  270. #------------------------------------------------------------------------------
  271. #  This window deals with menu command choices.
  272. #==============================================================================
  273.  
  274. class Window_MenuCommand < Window_Selectable
  275.   #--------------------------------------------------------------------------
  276.   # * include the CMS_Config module
  277.   #--------------------------------------------------------------------------
  278.   include CMS_Config
  279.  
  280.   # Object Initilization
  281.   def initialize
  282.     # Create Window
  283.     super(COMMAND_WINDOW[1], COMMAND_WINDOW[2], 640, 64)
  284.     self.contents = Bitmap.new(width - 32, height - 32)
  285.     # Determine items based on number of selections
  286.     @item_max = COMMAND_SETUP.size
  287.     @column_max = COMMAND_SETUP.size
  288.     @row_max = 1
  289.     @commands = COMMAND_SETUP
  290.     self.opacity = COMMAND_WINDOW[3]
  291.     refresh
  292.     self.index = 0
  293.   end
  294. #  alias tslums_menucmd_update update
  295. #  def update
  296. #    tslums_menucmd_update
  297. #  end
  298.   def refresh
  299.     self.contents.clear
  300.     for i in 0...@item_max
  301.       draw_item(i, system_color)
  302.     end
  303.   end
  304.  
  305.   def draw_item(index, color)
  306.     cursor_width = self.width / @column_max - 32
  307.     x = index % @column_max * (cursor_width + 32)
  308.     y = 0
  309.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  310.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  311.     # Check if menu icons are enabled
  312.     if ICON
  313.       # Get the menu icon from the icons folder based on menu item name using "Menu" folder
  314.       bitmap = RPG::Cache.icon(COMMAND_SETUP[index])
  315.       # Draw icons
  316.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))    
  317.       # Draw commands text
  318.       self.contents.draw_text(x + 16, y, cursor_width, 32, @commands[index], 0)
  319.     else
  320.       self.contents.draw_text(x, y, cursor_width, 32, @commands[index], 0)
  321.     end
  322.   end
  323.  
  324.   def disable_item(index)
  325.     draw_item(index, disabled_color)
  326.   end
  327.  
  328.   #--------------------------------------------------------------------------
  329.   # * Update Cursor Rectangle
  330.   #--------------------------------------------------------------------------
  331.   def update_cursor_rect
  332.     # If cursor position is less than 0
  333.     if @index < 0
  334.       self.cursor_rect.empty
  335.       return
  336.     end # if
  337.     # Calculate cursor coordinates
  338.     x = @index * (618 / COMMAND_SETUP.size)
  339.     y = 16
  340.     self.cursor_rect.set(-8 + x, -8, (640 / COMMAND_SETUP.size), 32)
  341.   end # def
  342.   #--------------------------------------------------------------------------
  343.   # * Dispose all of the windows
  344.   #--------------------------------------------------------------------------
  345.   def remove
  346.     self.dispose
  347.     for i in 0...@item_max
  348.       @winlist[i].dispose
  349.     end
  350.   end
  351.  
  352. end
  353.  
  354. #==============================================================================
  355. # ** Window_Blank
  356. #------------------------------------------------------------------------------
  357. #  This window deals with blank window backgrounds.
  358. #==============================================================================
  359.  
  360. class Window_Blank < Window_Base
  361.   #--------------------------------------------------------------------------
  362.   # * Object Initialization
  363.   #     x        : window x coordinate
  364.   #     y        : window y coordinate
  365.   #     width    : window width
  366.   #     height   : window height
  367.   #--------------------------------------------------------------------------
  368.   def initialize(x, y, width, height)
  369.     super(x, y, width, height)
  370.   end
  371. end
  372.  
  373. #==============================================================================
  374. # ** Info Menus
  375. #------------------------------------------------------------------------------
  376. #  These windows show time played, current map and gold
  377. #==============================================================================
  378.  
  379. class Window_Location < Window_Base
  380.   #--------------------------------------------------------------------------
  381.   # * include the CMS_Config module
  382.   #--------------------------------------------------------------------------
  383.   include CMS_Config
  384.   def initialize
  385.     super(LOCATION_WINDOW[1], LOCATION_WINDOW[2], LOCATION_WINDOW[5], LOCATION_WINDOW[6])
  386.     self.contents = Bitmap.new(width - 52, height - 32)
  387.     self.contents.font.size = LOCATION_WINDOW[7]
  388.     self.opacity = LOCATION_WINDOW[3]
  389.     refresh
  390.   end
  391.   def refresh
  392.     self.contents.clear
  393.     self.contents.font.color = normal_color
  394.     self.contents.font.size = 24
  395.     self.contents.draw_text( 0, 0, 640, 32, $game_map.name)
  396.   end
  397.   def update
  398.     super
  399.     if Graphics.frame_count / Graphics.frame_rate != @total_sec
  400.       refresh
  401.     end
  402.   end
  403. end
  404.  
  405. class Window_Gold < Window_Base
  406.   #--------------------------------------------------------------------------
  407.   # * include the CMS_Config module
  408.   #--------------------------------------------------------------------------
  409.   include CMS_Config
  410.  
  411.   def initialize
  412.     super(GOLD_WINDOW[1], GOLD_WINDOW[2], GOLD_WINDOW[5], GOLD_WINDOW[6])
  413.     self.contents = Bitmap.new(width - 32, height - 32)
  414.     self.contents.font.size = GOLD_WINDOW[7]
  415.     self.opacity = GOLD_WINDOW[3]
  416.     refresh
  417.     if GOLD_ICON != ""
  418.       bitmap = RPG::Cache.icon(GOLD_ICON)
  419.       self.contents.blt(0, 0 + 4, bitmap, Rect.new(0, 0, 24, 24))
  420.     end
  421.   end
  422.   def refresh
  423.     self.contents.clear
  424.     self.contents.font.color = system_color
  425.     self.contents.draw_text(4, 0, GOLD_WINDOW[5]-40, 32, $data_system.words.gold, 2)
  426.   end
  427. end
  428.  
  429. class Window_PlayTime < Window_Base
  430.   #--------------------------------------------------------------------------
  431.   # * include the CMS_Config module
  432.   #--------------------------------------------------------------------------
  433.   include CMS_Config
  434.  
  435.   def initialize
  436.     super(TIME_WINDOW[1], TIME_WINDOW[2], TIME_WINDOW[5], TIME_WINDOW[6])
  437.     self.contents = Bitmap.new(width - 32, height - 32)
  438.     self.contents.font.size = TIME_WINDOW[7]
  439.     self.opacity = TIME_WINDOW[3]
  440.     refresh
  441.     if TIME_ICON != ""
  442.       bitmap = RPG::Cache.icon(TIME_ICON)
  443.       self.contents.blt(0, TIME_WINDOW[7] + 4, bitmap, Rect.new(0, 0, 24, 24))
  444.     end
  445.   end
  446.   def refresh
  447.     self.contents.clear
  448.     self.contents.font.color = system_color
  449.     self.contents.draw_text(4, 0, TIME_WINDOW[5]-40, 32, "Play Time")
  450.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  451.     hour = @total_sec / 60 / 60
  452.     min = @total_sec / 60 % 60
  453.     sec = @total_sec % 60
  454.     text = sprintf("%02d:%02d:%02d", hour, min, sec)
  455.     self.contents.font.color = normal_color
  456.     self.contents.draw_text(4, 0, TIME_WINDOW[5]-40, 32, text, 2)
  457.   end
  458.    def update
  459.     super
  460.     if Graphics.frame_count / Graphics.frame_rate != @total_sec
  461.       refresh
  462.     end
  463.   end
  464. end
  465.  
  466.  
  467. #==============================================================================
  468. # ** Window_TargetMenu
  469. #------------------------------------------------------------------------------
  470. #  This window selects a use target for the actor on item and skill screens.
  471. #==============================================================================
  472.  
  473. class Window_TargetMenu < Window_Selectable
  474.   #--------------------------------------------------------------------------
  475.   # * include the CMS_Config module
  476.   #--------------------------------------------------------------------------
  477.   include CMS_Config
  478.  
  479.   #--------------------------------------------------------------------------
  480.   # * Object Initialization
  481.   #--------------------------------------------------------------------------
  482.   def initialize
  483.     super(0, 0, 336, 480)
  484.     @item_max = $game_party.actors.size
  485.     self.contents = Bitmap.new(width - 32, @item_max * 120 - 32)
  486.     self.z += 10
  487.     refresh
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # * Refresh
  491.   #--------------------------------------------------------------------------
  492.   def refresh
  493.     self.contents.clear
  494.     for i in 0...$game_party.actors.size
  495.       x = 4
  496.       y = i * 116
  497.       actor = $game_party.actors[i]
  498.       draw_actor_name(actor, x, y)
  499.       draw_actor_class(actor, x + 144, y)
  500.       draw_actor_level(actor, x + 8, y + 32)
  501.       draw_actor_state(actor, x + 8, y + 64)
  502.       draw_actor_hp(actor, x + 152, y + 32)
  503.       draw_actor_sp(actor, x + 152, y + 60)
  504.      
  505.       # Draw the hp and sp bars
  506.       # Initialize the image variables
  507.       bar_back = RPG::Cache.picture(SM_BARBACK)
  508.       hp_bar = RPG::Cache.picture(SM_HPBAR)
  509.       sp_bar = RPG::Cache.picture(SM_SPBAR)
  510.  
  511.       # Bar background
  512.       width = bar_back.width
  513.       height = bar_back.height
  514.       src_rect = Rect.new(0, 0, width, height)
  515.       self.contents.blt(x + 140, y + 56, bar_back, src_rect)
  516.       self.contents.blt(x + 140, y + 84, bar_back, src_rect)
  517.       # Heath bar
  518.       width = hp_bar.width * actor.hp / actor.maxhp
  519.       height = hp_bar.height
  520.       src_rect = Rect.new(0, 0, width, height)
  521.       self.contents.blt(x + 140, y + 56, hp_bar, src_rect)
  522.       # Magic bar
  523.       width = sp_bar.width * actor.sp / actor.maxsp
  524.       height = sp_bar.height
  525.       src_rect = Rect.new(0, 0, width, height)
  526.       self.contents.blt(x + 140, y + 84, sp_bar, src_rect)
  527.     end
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   # * Get Top Row
  531.   #--------------------------------------------------------------------------
  532.   def top_row
  533.     # Divide y-coordinate of window contents transfer origin by 1 row
  534.     # height of 120
  535.     return self.oy / 116
  536.   end
  537.   #--------------------------------------------------------------------------
  538.   # * Set Top Row
  539.   #     row : row shown on top
  540.   #--------------------------------------------------------------------------
  541.   def top_row=(row)
  542.     # If row is less than 0, change it to 0
  543.     if row < 0
  544.       row = 0
  545.     end
  546.     # If row exceeds row_max - 1, change it to row_max - 1
  547.     if row > row_max - 1
  548.       row = row_max - 1
  549.     end
  550.     # Multiply 1 row height by 120 for y-coordinate of window contents
  551.     # transfer origin
  552.     self.oy = row * 116
  553.   end
  554.   #--------------------------------------------------------------------------
  555.   # * Get Number of Rows Displayable on 1 Page
  556.   #--------------------------------------------------------------------------
  557.   def page_row_max
  558.     # Only allow 4 rows to be displayed at a time
  559.     return 4
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   # * Update Cursor Rectangle
  563.   #--------------------------------------------------------------------------
  564.   def update_cursor_rect
  565.     # If cursor position is less than 0
  566.     if @index < 0
  567.       self.cursor_rect.empty
  568.       return
  569.     end
  570.     # Get current row
  571.     row = @index / @column_max
  572.     # If current row is before top row
  573.     if row < self.top_row
  574.       # Scroll so that current row becomes top row
  575.       self.top_row = row
  576.     end
  577.     # If current row is more to back than back row
  578.     if row > self.top_row + (self.page_row_max - 1)
  579.       # Scroll so that current row becomes back row
  580.       self.top_row = row - (self.page_row_max - 1)
  581.     end
  582.     # Calculate cursor width
  583.     cursor_width = self.width / @column_max - 32
  584.     # Calculate cursor coordinates
  585.     x = @index % @column_max * (cursor_width + 32)
  586.     y = @index / @column_max * 116 - self.oy
  587.     # Update cursor rectangle
  588.     self.cursor_rect.set(x, y, cursor_width, 96)
  589.   end
  590. end
  591.  
  592. #==============================================================================
  593. # ** Window_EquipCurrent
  594. #------------------------------------------------------------------------------
  595. #  This window displays items the actor is currently equipped with on the
  596. #  equipment screen.
  597. #==============================================================================
  598.  
  599. class Window_EquipRight < Window_Selectable
  600.   #--------------------------------------------------------------------------
  601.   # * Object Initialization
  602.   #     actor : actor
  603.   #--------------------------------------------------------------------------
  604.   def initialize(actor)
  605.     super(0, 192, 320, 192)
  606.     self.contents = Bitmap.new(width - 32, height - 32)
  607.     self.opacity = 0
  608.     @actor = actor
  609.     refresh
  610.     self.index = 0
  611.   end
  612.   #--------------------------------------------------------------------------
  613.   # * Help Text Update
  614.   #--------------------------------------------------------------------------
  615.   def update_help
  616.     @help_window.set_text(self.item == nil ? "" : self.item.description, item)
  617.   end
  618. end
  619.  
  620. #==============================================================================
  621. # ** Window_EquipItem
  622. #------------------------------------------------------------------------------
  623. #  This window displays choices when opting to change equipment on the
  624. #  equipment screen.
  625. #==============================================================================
  626.  
  627. class Window_EquipItem < Window_Selectable
  628.   #--------------------------------------------------------------------------
  629.   # * Object Initialization
  630.   #     actor      : actor
  631.   #     equip_type : equip region (0-3)
  632.   #--------------------------------------------------------------------------
  633.   def initialize(actor, equip_type)
  634.     super(320, 0, 320, 384)
  635.     @actor = actor
  636.     @equip_type = equip_type
  637.     @column_max = 1
  638.     refresh
  639.     self.active = false
  640.     self.index = -1
  641.   end
  642.   #--------------------------------------------------------------------------
  643.   # * Item Acquisition
  644.   #--------------------------------------------------------------------------
  645.   def item
  646.     return @data[self.index]
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   # * Refresh
  650.   #--------------------------------------------------------------------------
  651.   def refresh
  652.     if self.contents != nil
  653.       self.contents.dispose
  654.       self.contents = nil
  655.     end
  656.     @data = []
  657.     # Add equippable weapons
  658.     if @equip_type == 0
  659.       weapon_set = $data_classes[@actor.class_id].weapon_set
  660.       for i in 1...$data_weapons.size
  661.         if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
  662.           @data.push($data_weapons[i])
  663.         end
  664.       end
  665.     end
  666.     # Add equippable armor
  667.     if @equip_type != 0
  668.       armor_set = $data_classes[@actor.class_id].armor_set
  669.       for i in 1...$data_armors.size
  670.         if $game_party.armor_number(i) > 0 and armor_set.include?(i)
  671.           if $data_armors[i].kind == @equip_type-1
  672.             @data.push($data_armors[i])
  673.           end
  674.         end
  675.       end
  676.     end
  677.     # Add blank page
  678.     @data.push(nil)
  679.     # Make a bit map and draw all items
  680.     @item_max = @data.size
  681.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  682.     for i in 0...@item_max-1
  683.       draw_item(i)
  684.     end
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # * Draw Item
  688.   #     index : item number
  689.   #--------------------------------------------------------------------------
  690.   def draw_item(index)
  691.     item = @data[index]
  692.     x = 4
  693.     y = index * 32
  694.     case item
  695.     when RPG::Weapon
  696.       number = $game_party.weapon_number(item.id)
  697.     when RPG::Armor
  698.       number = $game_party.armor_number(item.id)
  699.     end
  700.     bitmap = RPG::Cache.icon(item.icon_name)
  701.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  702.     self.contents.font.color = normal_color
  703.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  704.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  705.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  706.   end
  707.   #--------------------------------------------------------------------------
  708.   # * Help Text Update
  709.   #--------------------------------------------------------------------------
  710.   def update_help
  711.     @help_window.set_text(self.item == nil ? "" : self.item.description, item)
  712.   end
  713. end
  714.  
  715. #==============================================================================
  716. # ** Window_EquipLeft
  717. #------------------------------------------------------------------------------
  718. #  This window displays actor parameter changes on the equipment screen.
  719. #==============================================================================
  720.  
  721. class Window_EquipLeft < Window_Base
  722.   #--------------------------------------------------------------------------
  723.   # * Object Initialization
  724.   #     actor : actor
  725.   #--------------------------------------------------------------------------
  726.   def initialize(actor)
  727.     super(0, 0, 320, 384)
  728.     self.contents = Bitmap.new(width - 32, height - 32)
  729.     @actor = actor
  730.     refresh
  731.   end
  732.   #--------------------------------------------------------------------------
  733.   # * Refresh
  734.   #--------------------------------------------------------------------------
  735.   def refresh
  736.     x = 16
  737.     y = 24
  738.     self.contents.clear
  739.     self.contents.font.color = system_color
  740.     self.contents.draw_text(x+4, y+0, 120, 32, "HP")
  741.     self.contents.draw_text(x+4, y+32, 120, 32, "SP")
  742.     self.contents.font.color = normal_color
  743.     self.contents.draw_text(x+124, y+0, 36, 32, @actor.maxhp.to_s, 2)
  744.     self.contents.draw_text(x+124, y+32, 36, 32, @actor.maxsp.to_s, 2)
  745.     draw_actor_parameter(@actor, x+4, y+64, 0)
  746.     draw_actor_parameter(@actor, x+4, y+96, 1)
  747.     draw_actor_parameter(@actor, x+4, y+128, 2)
  748.     draw_actor_parameter(@actor, x+4, y+160, 3)
  749.     draw_actor_parameter(@actor, x+4, y+192, 4)
  750.     draw_actor_parameter(@actor, x+4, y+224, 5)
  751.     draw_actor_parameter(@actor, x+4, y+256, 6)
  752.     if @new_maxhp != nil
  753.       self.contents.font.color = system_color
  754.       self.contents.draw_text(x+160, y+0, 40, 32, "->", 1)
  755.       if @new_maxhp > @actor.maxhp
  756.         self.contents.font.color = text_color(3)
  757.       elsif @new_maxhp < @actor.maxhp
  758.         self.contents.font.color = text_color(2)
  759.       else
  760.         self.contents.font.color = normal_color
  761.       end
  762.       self.contents.draw_text(x+200, y+0, 36, 32, @new_maxhp.to_s, 2)
  763.     end
  764.     if @new_maxsp != nil
  765.       self.contents.font.color = system_color
  766.       self.contents.draw_text(x+160, y+32, 40, 32, "->", 1)
  767.       if @new_maxsp > @actor.maxsp
  768.         self.contents.font.color = text_color(3)
  769.       elsif @new_maxsp < @actor.maxsp
  770.         self.contents.font.color = text_color(2)
  771.       else
  772.         self.contents.font.color = normal_color
  773.       end
  774.       self.contents.draw_text(x+200, y+32, 36, 32, @new_maxsp.to_s, 2)
  775.     end
  776.     if @new_atk != nil
  777.       self.contents.font.color = system_color
  778.       self.contents.draw_text(x+160, y+64, 40, 32, "->", 1)
  779.       if @new_atk > @actor.atk
  780.         self.contents.font.color = text_color(3)
  781.       elsif @new_atk < @actor.atk
  782.         self.contents.font.color = text_color(2)
  783.       else
  784.         self.contents.font.color = normal_color
  785.       end
  786.       self.contents.draw_text(x+200, y+64, 36, 32, @new_atk.to_s, 2)
  787.     end
  788.     if @new_pdef != nil
  789.       self.contents.font.color = system_color
  790.       self.contents.draw_text(x+160, y+96, 40, 32, "->", 1)
  791.       if @new_pdef > @actor.pdef
  792.         self.contents.font.color = text_color(3)
  793.       elsif @new_pdef < @actor.pdef
  794.         self.contents.font.color = text_color(2)
  795.       else
  796.         self.contents.font.color = normal_color
  797.       end
  798.       self.contents.draw_text(x+200, y+96, 36, 32, @new_pdef.to_s, 2)
  799.     end
  800.     if @new_mdef != nil
  801.       self.contents.font.color = system_color
  802.       self.contents.draw_text(x+160, y+128, 40, 32, "->", 1)
  803.       if @new_mdef > @actor.mdef
  804.         self.contents.font.color = text_color(3)
  805.       elsif @new_mdef < @actor.mdef
  806.         self.contents.font.color = text_color(2)
  807.       else
  808.         self.contents.font.color = normal_color
  809.       end
  810.       self.contents.draw_text(x+200, y+128, 36, 32, @new_mdef.to_s, 2)
  811.     end
  812.     if @new_str != nil
  813.       self.contents.font.color = system_color
  814.       self.contents.draw_text(x+160, y+160, 40, 32, "->", 1)
  815.       if @new_str > @actor.str
  816.         self.contents.font.color = text_color(3)
  817.       elsif @new_str < @actor.str
  818.         self.contents.font.color = text_color(2)
  819.       else
  820.         self.contents.font.color = normal_color
  821.       end
  822.       self.contents.draw_text(x+200, y+160, 36, 32, @new_str.to_s, 2)
  823.     end
  824.     if @new_dex != nil
  825.       self.contents.font.color = system_color
  826.       self.contents.draw_text(x+160, y+192, 40, 32, "->", 1)
  827.       if @new_dex > @actor.dex
  828.         self.contents.font.color = text_color(3)
  829.       elsif @new_dex < @actor.dex
  830.         self.contents.font.color = text_color(2)
  831.       else
  832.         self.contents.font.color = normal_color
  833.       end
  834.       self.contents.draw_text(x+200, y+192, 36, 32, @new_dex.to_s, 2)
  835.     end
  836.     if @new_agi != nil
  837.       self.contents.font.color = system_color
  838.       self.contents.draw_text(x+160, y+224, 40, 32, "->", 1)
  839.       if @new_agi > @actor.agi
  840.         self.contents.font.color = text_color(3)
  841.       elsif @new_agi < @actor.agi
  842.         self.contents.font.color = text_color(2)
  843.       else
  844.         self.contents.font.color = normal_color
  845.       end
  846.       self.contents.draw_text(x+200, y+224, 36, 32, @new_agi.to_s, 2)
  847.     end
  848.     if @new_int != nil
  849.       self.contents.font.color = system_color
  850.       self.contents.draw_text(x+160, y+256, 40, 32, "->", 1)
  851.       if @new_int > @actor.int
  852.         self.contents.font.color = text_color(3)
  853.       elsif @new_int < @actor.int
  854.         self.contents.font.color = text_color(2)
  855.       else
  856.         self.contents.font.color = normal_color
  857.       end
  858.       self.contents.draw_text(x+200, y+256, 36, 32, @new_int.to_s, 2)
  859.     end
  860.   end
  861.   #--------------------------------------------------------------------------
  862.   # * Set parameters after changing equipment
  863.   #     new_atk  : attack power after changing equipment
  864.   #     new_pdef : physical defense after changing equipment
  865.   #     new_mdef : magic defense after changing equipment
  866.   #--------------------------------------------------------------------------
  867.   def set_new_parameters(new_atk, new_pdef, new_mdef, new_maxhp, new_maxsp, new_str, new_dex, new_agi, new_int)
  868.     if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef or @new_maxhp != new_maxhp or @new_maxsp != new_maxsp or @new_str != new_str or @new_dex != new_dex or @new_agi != new_agi or @new_int != new_int
  869.       @new_maxhp = new_maxhp
  870.       @new_maxsp = new_maxsp
  871.       @new_atk = new_atk
  872.       @new_pdef = new_pdef
  873.       @new_mdef = new_mdef
  874.       @new_str = new_str
  875.       @new_dex = new_dex
  876.       @new_agi = new_agi
  877.       @new_int = new_int
  878.       refresh      
  879.     end
  880.   end
  881. end
  882.  
  883. #==============================================================================
  884. # ** Window_EquipStatus
  885. #------------------------------------------------------------------------------
  886. #  This window shows the actors status.
  887. #==============================================================================
  888. class Window_EquipStatus < Window_Base
  889.   include CMS_Config
  890.  
  891.   def initialize(actor)
  892.     super(0, 0, 320, 384)
  893.     self.contents = Bitmap.new(width - 32, height - 32)
  894.     @actor = actor
  895.     refresh
  896.   end
  897.   #--------------------------------------------------------------------------
  898.   # * Refresh
  899.   #--------------------------------------------------------------------------
  900.   def refresh
  901.     self.contents.clear
  902.     x = 4
  903.     # Draw all the infomation for the player
  904.     face = RPG::Cache.picture("Faces/" + $change_face.face(@actor.id))
  905.     src_rect = Rect.new(0, 0, face.width, face.height)
  906.     self.contents.blt(64 - face.width/2, 32, face, src_rect)
  907.     draw_actor_name(@actor, x + 96, 0)
  908.     draw_actor_class(@actor, x + 128, 32)
  909.     draw_actor_level(@actor, x + 204, 0)
  910.     draw_actor_hp(@actor, x + 128, 64)
  911.     draw_actor_sp(@actor, x + 128, 108)
  912.    
  913.     # Draw the hp and sp bars
  914.     # Initialize the image variables
  915.     bar_back = RPG::Cache.picture(SM_BARBACK)
  916.     hp_bar = RPG::Cache.picture(SM_HPBAR)
  917.     sp_bar = RPG::Cache.picture(SM_SPBAR)
  918.  
  919.     # Bar background
  920.     width = bar_back.width
  921.     height = bar_back.height
  922.     src_rect = Rect.new(0, 0, width, height)
  923.     self.contents.blt(x + 128, 88, bar_back, src_rect)
  924.     self.contents.blt(x + 128, 132, bar_back, src_rect)
  925.     # Heath bar
  926.     width = hp_bar.width * @actor.hp / @actor.maxhp
  927.     height = hp_bar.height
  928.     src_rect = Rect.new(0, 0, width, height)
  929.     self.contents.blt(x + 128, 88, hp_bar, src_rect)
  930.     # Magic bar
  931.     width = sp_bar.width * @actor.sp / @actor.maxsp
  932.     height = sp_bar.height
  933.     src_rect = Rect.new(0, 0, width, height)
  934.     self.contents.blt(x + 128, 132, sp_bar, src_rect)
  935.   end
  936. end
  937.  
  938. #==============================================================================
  939. # ** Window_EquipHelp
  940. #------------------------------------------------------------------------------
  941. #  This window shows item explanations along with the icon.
  942. #==============================================================================
  943.  
  944. class Window_EquipHelp < Window_Base
  945.   #--------------------------------------------------------------------------
  946.   # * Object Initialization
  947.   #--------------------------------------------------------------------------
  948.   def initialize
  949.     super(0, 384, 640, 96)
  950.     self.contents = Bitmap.new(width - 32, height - 32)
  951.   end
  952.   #--------------------------------------------------------------------------
  953.   # * Set Text
  954.   #  text  : text string displayed in window
  955.   #  align : alignment (0..flush left, 1..center, 2..flush right)
  956.   #--------------------------------------------------------------------------
  957.   def set_text(text, item, align = 0)
  958.     # If at least one part of text and alignment differ from last time
  959.     if text != @text or align != @align
  960.       # Redraw text
  961.       self.contents.clear
  962.       # Redraw icon
  963.       if item
  964.         bitmap = RPG::Cache.icon(item.icon_name)
  965.         width = bitmap.width
  966.         height = bitmap.height
  967.         src_rect = Rect.new(0, 0, width, height)
  968.         dest_rect = Rect.new(0, 8, width * 2, height * 2)
  969.         self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  970.       else
  971.         width = 0
  972.       end
  973.       self.contents.font.color = normal_color
  974.       self.contents.draw_text(4 + width * 2, 16, self.width - 40, 32, text, align)
  975.       @text = text
  976.       @align = align
  977.       @actor = nil
  978.     end
  979.     self.visible = true
  980.   end
  981.   #--------------------------------------------------------------------------
  982.   # * Set Actor
  983.   #     actor : status displaying actor
  984.   #--------------------------------------------------------------------------
  985.   def set_actor(actor)
  986.     if actor != @actor
  987.       self.contents.clear
  988.       draw_actor_name(actor, 4, 0)
  989.       draw_actor_state(actor, 140, 0)
  990.       draw_actor_hp(actor, 284, 0)
  991.       draw_actor_sp(actor, 460, 0)
  992.       @actor = actor
  993.       @text = nil
  994.       self.visible = true
  995.     end
  996.   end
  997.   #--------------------------------------------------------------------------
  998.   # * Set Enemy
  999.   #     enemy : name and status displaying enemy
  1000.   #--------------------------------------------------------------------------
  1001.   def set_enemy(enemy)
  1002.     text = enemy.name
  1003.     state_text = make_battler_state_text(enemy, 112, false)
  1004.     if state_text != ""
  1005.       text += "  " + state_text
  1006.     end
  1007.     set_text(text, 1, 1)
  1008.   end
  1009. end
  1010.  
  1011. #==============================================================================
  1012. # ** Window_SaveFile
  1013. #------------------------------------------------------------------------------
  1014. #  This window displays save files on the save and load screens.
  1015. #==============================================================================
  1016.  
  1017. class Window_SaveFile < Window_Base
  1018.   #--------------------------------------------------------------------------
  1019.   # * Public Instance Variables
  1020.   #--------------------------------------------------------------------------
  1021.   attr_reader   :filename                 # file name
  1022.   attr_reader   :selected                 # selected
  1023.   #--------------------------------------------------------------------------
  1024.   # * Object Initialization
  1025.   #     file_index : save file index (0-3)
  1026.   #     filename   : file name
  1027.   #--------------------------------------------------------------------------
  1028.   def initialize(file_index, filename)
  1029.     super(0, 64 + file_index % 4 * 104, 640, 104)
  1030.     self.contents = Bitmap.new(width - 32, height - 32)
  1031.     @file_index = file_index
  1032.     @filename = "Save#{@file_index + 1}.rxdata"
  1033.     @time_stamp = Time.at(0)
  1034.     @file_exist = FileTest.exist?(@filename)
  1035.     if @file_exist
  1036.       file = File.open(@filename, "r")
  1037.       @time_stamp = file.mtime
  1038.       @characters = Marshal.load(file)
  1039.       @frame_count = Marshal.load(file)
  1040.       @game_system = Marshal.load(file)
  1041.       @game_switches = Marshal.load(file)
  1042.       @game_variables = Marshal.load(file)
  1043.       @game_self_switches = Marshal.load(file)
  1044.       @game_screen = Marshal.load(file)
  1045.       @game_actors = Marshal.load(file)
  1046.       @game_party = Marshal.load(file)
  1047.       @game_troop = Marshal.load(file)
  1048.       @game_map = Marshal.load(file)
  1049.       @total_sec = @frame_count / Graphics.frame_rate
  1050.       file.close
  1051.     end
  1052.     refresh
  1053.     @selected = false
  1054.   end
  1055.   #--------------------------------------------------------------------------
  1056.   # * Refresh
  1057.   #--------------------------------------------------------------------------
  1058.   def refresh
  1059.     self.contents.clear
  1060.     # Draw file number
  1061.     self.contents.font.color = normal_color
  1062.     name = "File#{@file_index + 1}"
  1063.     self.contents.draw_text(4, 0, 600, 32, name)
  1064.     @name_width = contents.text_size(name).width
  1065.     # If save file exists
  1066.     if @file_exist
  1067.       # Draw character
  1068.       for i in 0...@characters.size
  1069.         bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
  1070.         cw = bitmap.rect.width / 4
  1071.         ch = bitmap.rect.height / 4
  1072.         src_rect = Rect.new(0, 0, cw, ch)
  1073.         x = 320 - @characters.size * 16 + i * 32 - cw / 2
  1074.         self.contents.blt(x, 52 - ch, bitmap, src_rect)
  1075.       end
  1076.       # Draw play time
  1077.       hour = @total_sec / 60 / 60
  1078.       min = @total_sec / 60 % 60
  1079.       sec = @total_sec % 60
  1080.       time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  1081.       self.contents.font.color = normal_color
  1082.       self.contents.draw_text(48, 44, 512, 32, time_string)
  1083.       self.contents.draw_text(48, 44, 512, 32, "Location: " + @game_map.name.to_s, 2)
  1084.       self.contents.draw_text(48, 44, 412, 32, @game_party.gold.to_s + " " + $data_system.words.gold, 1)
  1085.     end
  1086.   end
  1087.   #--------------------------------------------------------------------------
  1088.   # * Set Selected
  1089.   #     selected : new selected (true = selected, false = unselected)
  1090.   #--------------------------------------------------------------------------
  1091.   def selected=(selected)
  1092.     @selected = selected
  1093.     update_cursor_rect
  1094.   end
  1095.   #--------------------------------------------------------------------------
  1096.   # * Cursor Rectangle Update
  1097.   #--------------------------------------------------------------------------
  1098.   def update_cursor_rect
  1099.     if @selected
  1100.       self.cursor_rect.set(0, 0, @name_width + 8, 32)
  1101.     else
  1102.       self.cursor_rect.empty
  1103.     end
  1104.   end
  1105. end
  1106.  
  1107. #==============================================================================
  1108. # ** Window_Item
  1109. #------------------------------------------------------------------------------
  1110. #  This window displays items in possession on the item and battle screens.
  1111. #==============================================================================
  1112.  
  1113. class Window_ItemMenu < Window_Selectable
  1114.   #--------------------------------------------------------------------------
  1115.   # * Object Initialization
  1116.   #--------------------------------------------------------------------------
  1117.   def initialize
  1118.     super(0, 64, 640, 352)
  1119.     @column_max = 2
  1120.     @category = 0
  1121.     refresh
  1122.     self.index = -1
  1123.     @category_select = true
  1124.     # If in battle, move window to center of screen
  1125.     # and make it semi-transparent
  1126.     if $game_temp.in_battle
  1127.       self.y = 64
  1128.       self.height = 256
  1129.       self.back_opacity = 160
  1130.     end
  1131.   end
  1132.   #--------------------------------------------------------------------------
  1133.   # * Get Item
  1134.   #--------------------------------------------------------------------------
  1135.   def item
  1136.     case @category
  1137.     when 0
  1138.       if @item_max > 20
  1139.         return @recent[self.index + (@item_max - 20)]
  1140.       else
  1141.         return @recent[self.index]
  1142.       end
  1143.     when 1
  1144.       return @consumable[self.index]
  1145.     when 2
  1146.       return @weapon[self.index]
  1147.     when 3
  1148.       return @body[self.index]
  1149.     when 4
  1150.       return @head[self.index]
  1151.     when 5
  1152.       return @arm[self.index]
  1153.     when 6
  1154.       return @accessory[self.index]
  1155.     when 7
  1156.       return @raw[self.index]
  1157.     when 8
  1158.       return @quest[self.index]
  1159.     end
  1160.   end
  1161.   #--------------------------------------------------------------------------
  1162.   # * Set Category
  1163.   #--------------------------------------------------------------------------
  1164.   def category(index)
  1165.     @category = index
  1166.   end
  1167.   #--------------------------------------------------------------------------
  1168.   # * Repaint
  1169.   #--------------------------------------------------------------------------
  1170.   def repaint
  1171.     refresh
  1172.     if @category == 0
  1173.       @item_max = @recent.size
  1174.     elsif @category == 1
  1175.       @item_max = @consumable.size
  1176.     elsif @category == 2
  1177.       @item_max = @weapon.size
  1178.     elsif @category == 3
  1179.       @item_max = @body.size
  1180.     elsif @category == 4
  1181.       @item_max = @head.size
  1182.     elsif @category == 5
  1183.       @item_max = @arm.size
  1184.     elsif @category == 6
  1185.       @item_max = @accessory.size
  1186.     elsif @category == 7
  1187.       @item_max = @raw.size
  1188.     elsif @category == 8
  1189.       @item_max = @quest.size
  1190.     end
  1191.     if @item_max == 0
  1192.       self.contents.dispose if self.contents != nil
  1193.       self.contents = Bitmap.new(width - 32, height - 32)
  1194.     end
  1195.       if @item_max > 20 && @category == 0
  1196.         self.contents = Bitmap.new(width - 32, height - 32)
  1197.         for i in @item_max-20...@item_max
  1198.           draw_item(i)
  1199.         end
  1200.       elsif @item_max > 0
  1201.         self.contents = Bitmap.new(width - 32, row_max * 32)
  1202.         for i in 0...@item_max
  1203.           draw_item(i)
  1204.         end
  1205.       end
  1206.   end
  1207.   #--------------------------------------------------------------------------
  1208.   # * Refresh
  1209.   #--------------------------------------------------------------------------
  1210.   def refresh
  1211.     if self.contents != nil
  1212.       self.contents.dispose
  1213.       self.contents = nil
  1214.     end
  1215.    
  1216.     @recent = []
  1217.     @consumable = []
  1218.     @weapon = []
  1219.     @body = []
  1220.     @head = []
  1221.     @arm = []
  1222.     @accessory = []
  1223.     @raw = []
  1224.     @quest = []
  1225.     # Add item
  1226.     for i in 1...$data_items.size
  1227.       if $game_party.item_number(i) > 0
  1228.         # Add recent items
  1229.         if $recent_items.size < 20
  1230.           for u in 0...$recent_items.size
  1231.             if $data_items[i].id == $recent_items[u].id && $recent_items[u].is_a?(RPG::Item)
  1232.               @recent[($recent_items.size - 1) - u] = ($data_items[i])
  1233.             end
  1234.           end
  1235.         else
  1236.           for u in $recent_items.size-20...$recent_items.size
  1237.             if $data_items[i].id == $recent_items[u].id && $recent_items[u].is_a?(RPG::Item)
  1238.               @recent[21 - (u - ($recent_items.size-20))] = ($data_items[i])
  1239.             end
  1240.           end
  1241.         end
  1242.        
  1243.         # Add consumable, raw and quest items
  1244.         if $data_items[i].consumable
  1245.           if $data_items[i].occasion == 3
  1246.             @raw.push($data_items[i])
  1247.           else
  1248.             @consumable.push($data_items[i])
  1249.           end
  1250.         else
  1251.           @quest.push($data_items[i])
  1252.         end
  1253.       end
  1254.     end
  1255.    
  1256.     # Also add weapons and armors if outside of battle
  1257.     unless $game_temp.in_battle
  1258.       for i in 1...$data_weapons.size
  1259.         if $game_party.weapon_number(i) > 0
  1260.           # Add recent items
  1261.           if $recent_items.size < 20
  1262.             for u in 0...$recent_items.size
  1263.               if $data_weapons[i].id == $recent_items[u].id && $recent_items[u].is_a?(RPG::Weapon)
  1264.                 @recent[($recent_items.size - 1) - u] = ($data_weapons[i])
  1265.               end
  1266.             end
  1267.           else
  1268.             for u in $recent_items.size-20...$recent_items.size
  1269.               if $data_weapons[i].id == $recent_items[u].id && $recent_items[u].is_a?(RPG::Weapon)
  1270.                 @recent[21 - (u - ($recent_items.size-20))] = ($data_weapons[i])
  1271.               end
  1272.             end
  1273.           end
  1274.          
  1275.           # Add weapons
  1276.           @weapon.push($data_weapons[i])
  1277.         end
  1278.       end
  1279.       for i in 1...$data_armors.size
  1280.         if $game_party.armor_number(i) > 0
  1281.           # Add recent armors
  1282.           if $recent_items.size < 20
  1283.             for u in 0...$recent_items.size
  1284.               if $data_armors[i].id == $recent_items[u].id && $recent_items[u].is_a?(RPG::Armor)
  1285.                 @recent[($recent_items.size - 1) - u] = ($data_armors[i])
  1286.               end
  1287.             end
  1288.           else
  1289.             for u in $recent_items.size-20...$recent_items.size
  1290.               if $data_armors[i].id == $recent_items[u].id && $recent_items[u].is_a?(RPG::Armor)
  1291.                 @recent[21 - (u - ($recent_items.size-20))] = ($data_armors[i])
  1292.               end
  1293.             end
  1294.           end
  1295.          
  1296.           # Add armors
  1297.           if $data_armors[i].kind == 2 # Body Armor
  1298.             @body.push($data_armors[i])
  1299.           elsif $data_armors[i].kind == 1 # Head Armor
  1300.             @head.push($data_armors[i])
  1301.           elsif $data_armors[i].kind == 0 # Arm Armor
  1302.             @arm.push($data_armors[i])
  1303.           elsif $data_armors[i].kind == 3 # Accessories
  1304.             @accessory.push($data_armors[i])
  1305.           end
  1306.         end
  1307.       end
  1308.     end
  1309.     #repaint
  1310.   end
  1311.   #--------------------------------------------------------------------------
  1312.   # * Draw Item
  1313.   #     index : item number
  1314.   #--------------------------------------------------------------------------
  1315.   def draw_item(index)
  1316.     case @category
  1317.     when 0
  1318.       item = @recent[index]
  1319.     when 1
  1320.       item = @consumable[index]
  1321.     when 2
  1322.       item = @weapon[index]
  1323.     when 3
  1324.       item = @body[index]
  1325.     when 4
  1326.       item = @head[index]
  1327.     when 5
  1328.       item = @arm[index]
  1329.     when 6
  1330.       item = @accessory[index]
  1331.     when 7
  1332.       item = @raw[index]
  1333.     when 8
  1334.       item = @quest[index]
  1335.     end
  1336.     case item
  1337.     when RPG::Item
  1338.       number = $game_party.item_number(item.id)
  1339.     when RPG::Weapon
  1340.       number = $game_party.weapon_number(item.id)
  1341.     when RPG::Armor
  1342.       number = $game_party.armor_number(item.id)
  1343.     end
  1344.     if item.is_a?(RPG::Item) and
  1345.        $game_party.item_can_use?(item.id)
  1346.       self.contents.font.color = normal_color
  1347.     else
  1348.       self.contents.font.color = disabled_color
  1349.     end
  1350.     x = 4 + index % 2 * (288 + 32)
  1351.     if @item_max > 20 && @category == 0
  1352.       y = (index - (@item_max - 20)) / 2 * 32
  1353.     else
  1354.       y = index / 2 * 32
  1355.     end
  1356.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  1357.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  1358.     bitmap = RPG::Cache.icon(item.icon_name)
  1359.     opacity = self.contents.font.color == normal_color ? 255 : 128
  1360.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  1361.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  1362.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  1363.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  1364.   end
  1365.   #--------------------------------------------------------------------------
  1366.   # * Help Text Update
  1367.   #--------------------------------------------------------------------------
  1368.   def update_help
  1369.     if @index >= 0
  1370.       @help_window.set_text(self.item == nil ? "" : self.item.description, self.item)
  1371.     end
  1372.   end
  1373.   #--------------------------------------------------------------------------
  1374.   # * Frame Update
  1375.   #--------------------------------------------------------------------------
  1376.   def update
  1377.     if self.active and @item_max >= 0 and @index >= 0
  1378.       if Input.trigger?(Input::UP) && @index <= 1
  1379.         @index = -1
  1380.       end
  1381.     end
  1382.     super
  1383.   end
  1384.   def cat_select(tf)
  1385.     @category_select = tf
  1386.   end
  1387.   #--------------------------------------------------------------------------
  1388.   # * Update Cursor Rectangle
  1389.   #--------------------------------------------------------------------------
  1390.   def update_cursor_rect
  1391.     # If cursor position is less than 0
  1392.     if @index < 0 || @category_select
  1393.       self.cursor_rect.empty
  1394.       return
  1395.     end
  1396.     # Get current row
  1397.     row = @index / @column_max
  1398.     # If current row is before top row
  1399.     if row < self.top_row
  1400.       # Scroll so that current row becomes top row
  1401.       self.top_row = row
  1402.     end
  1403.     # If current row is more to back than back row
  1404.     if row > self.top_row + (self.page_row_max - 1)
  1405.       # Scroll so that current row becomes back row
  1406.       self.top_row = row - (self.page_row_max - 1)
  1407.     end
  1408.     # Calculate cursor width
  1409.     cursor_width = self.width / @column_max - 32
  1410.     # Calculate cursor coordinates
  1411.     x = @index % @column_max * (cursor_width + 32)
  1412.     y = @index / @column_max * 32 - self.oy
  1413.     # Update cursor rectangle
  1414.     self.cursor_rect.set(x, y, cursor_width, 32)
  1415.   end
  1416.   #--------------------------------------------------------------------------
  1417.   # * Draw Items after use
  1418.   #--------------------------------------------------------------------------
  1419.   def draw_items(index)
  1420.     if @category == 0 && @recent.size > 20
  1421.       draw_item(index + (@item_max - 20))
  1422.     else
  1423.       draw_item(index)
  1424.     end
  1425.   end
  1426. end
  1427.  
  1428. #==============================================================================
  1429. # ** Window_Category
  1430. #------------------------------------------------------------------------------
  1431. #  This window deals with item category command choices.
  1432. #==============================================================================
  1433.  
  1434. class Window_Category < Window_Selectable
  1435.   #--------------------------------------------------------------------------
  1436.   # * include the CMS_Config module
  1437.   #--------------------------------------------------------------------------
  1438.   include CMS_Config
  1439.  
  1440.   #--------------------------------------------------------------------------
  1441.   # * Object Initialization
  1442.   #     width    : window width
  1443.   #     commands : command text string array
  1444.   #--------------------------------------------------------------------------
  1445.   def initialize(width, commands)
  1446.     # Compute window height from command quantity
  1447.     super(200, 0, width, 64)
  1448.     @column_max = 9
  1449.     @item_max = commands.size
  1450.     @commands = commands
  1451.     self.contents = Bitmap.new(width - 32, height - 32)
  1452.     refresh
  1453.     self.index = 0
  1454.     self.opacity = 0
  1455.   end
  1456.   #--------------------------------------------------------------------------
  1457.   # * Refresh
  1458.   #--------------------------------------------------------------------------
  1459.   def refresh
  1460.     self.contents.clear
  1461.     for i in 0...@item_max
  1462.       draw_item(i, normal_color)
  1463.     end
  1464.   end
  1465.   #--------------------------------------------------------------------------
  1466.   # * Draw Item
  1467.   #     index : item number
  1468.   #     color : text color
  1469.   #--------------------------------------------------------------------------
  1470.   def draw_item(index, color)
  1471.     self.contents.font.color = color
  1472.     rect = Rect.new(76+ 32 * index,0, 32, 32)
  1473.     self.contents.fill_rect(rect, color)
  1474.     rect = Rect.new(77+ 32 * index,1, 30, 30)
  1475.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  1476.     self.contents.draw_text(0,0,100,32,@selection.to_s)
  1477.     rect = Rect.new(0, 0, 24, 24)
  1478.     bitmap = RPG::Cache.icon(ITEMS_MENU_ICONS[index])
  1479.     self.contents.blt(80 + 32 * index, 4, bitmap, rect)
  1480.   end
  1481.   #--------------------------------------------------------------------------
  1482.   # * Disable Item
  1483.   #     index : item number
  1484.   #--------------------------------------------------------------------------
  1485.   def disable_item(index)
  1486.     draw_item(index, disabled_color)
  1487.   end
  1488.   #--------------------------------------------------------------------------
  1489.   # * Update Cursor Rectangle
  1490.   #--------------------------------------------------------------------------
  1491.   def update_cursor_rect
  1492.     # If cursor position is less than 0
  1493.     if @index < 0
  1494.       self.cursor_rect.empty
  1495.       return
  1496.     end
  1497.     # Update cursor rectangle
  1498.     self.cursor_rect.set(76+@index*32, 0, 32, 32)
  1499.   end
  1500.   #--------------------------------------------------------------------------
  1501.   # * Help Text Update
  1502.   #--------------------------------------------------------------------------
  1503.   def update_help
  1504.     @help_window.set_display(ITEMS_MENU_TEXT[self.index], ITEMS_MENU_ICONS[self.index])
  1505.   end
  1506. end
  1507.  
  1508. #==============================================================================
  1509. # ** Window_ItemTop
  1510. #------------------------------------------------------------------------------
  1511. #  This window shows top bar with the title "Items" on it.
  1512. #==============================================================================
  1513.  
  1514. class Window_ItemTop < Window_Base
  1515.   #--------------------------------------------------------------------------
  1516.   # * Object Initialization
  1517.   #--------------------------------------------------------------------------
  1518.   def initialize
  1519.     super(0, 0, 640, 64)
  1520.     self.contents = Bitmap.new(width - 32, height - 32)
  1521.     refresh
  1522.   end
  1523.   #--------------------------------------------------------------------------
  1524.   # * Refresh
  1525.   #--------------------------------------------------------------------------
  1526.   def refresh
  1527.     self.contents.clear
  1528.     self.contents.font.color = system_color
  1529.     self.contents.font.size = 32
  1530.     self.contents.draw_text(0, 0, 100, 32, "Items")
  1531.     self.contents.font.size = 24    
  1532.   end
  1533.   #--------------------------------------------------------------------------
  1534.   # * Frame Update
  1535.   #--------------------------------------------------------------------------
  1536.   def update
  1537.     self.contents.clear
  1538.     self.contents.font.color = system_color
  1539.     self.contents.font.size = 32
  1540.     self.contents.draw_text(0, 0, 100, 32, "Items")
  1541.     self.contents.font.size = 24
  1542.   end
  1543. end
  1544.  
  1545. #==============================================================================
  1546. # ** Window_ItemHelp
  1547. #------------------------------------------------------------------------------
  1548. #  This window shows skill and item explanations along with actor status.
  1549. #==============================================================================
  1550.  
  1551. class Window_ItemHelp < Window_Base
  1552.   #--------------------------------------------------------------------------
  1553.   # * Object Initialization
  1554.   #--------------------------------------------------------------------------
  1555.   def initialize
  1556.     super(0, 0, 640, 128)
  1557.     self.contents = Bitmap.new(width - 32, height - 32)
  1558.     self.opacity = 0
  1559.   end
  1560.   #--------------------------------------------------------------------------
  1561.   # * Set Text
  1562.   #  text  : text string displayed in window
  1563.   #  align : alignment (0..flush left, 1..center, 2..flush right)
  1564.   #--------------------------------------------------------------------------
  1565.   def set_text(text, item, align = 0)
  1566.     # If at least one part of text and alignment differ from last time
  1567.     if text != @text or align != @align
  1568.       # Redraw text
  1569.       self.contents.clear
  1570.       # Redraw icon
  1571.       if item
  1572.         bitmap = RPG::Cache.icon(item.icon_name)
  1573.         width = bitmap.width
  1574.         height = bitmap.height
  1575.         src_rect = Rect.new(0, 0, width, height)
  1576.         dest_rect = Rect.new(0, 24, width * 2, height * 2)
  1577.         self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  1578.       else
  1579.         width = 0
  1580.       end
  1581.       self.contents.font.color = normal_color
  1582.       self.contents.draw_text(4 + width * 2, 32, self.width - 40, 32, text, align)
  1583.       @text = text
  1584.       @align = align
  1585.       @actor = nil
  1586.     end
  1587.     self.visible = true
  1588.   end
  1589.   #--------------------------------------------------------------------------
  1590.   # * Set Display
  1591.   #  text  : text string displayed in window
  1592.   #  align : alignment (0..flush left, 1..center, 2..flush right)
  1593.   #--------------------------------------------------------------------------
  1594.   def set_display(text, icon, align = 0)
  1595.     # If at least one part of text and alignment differ from last time
  1596.     if text != @text or align != @align
  1597.       # Redraw text
  1598.       self.contents.clear
  1599.       # Redraw icon
  1600.       if icon
  1601.         bitmap = RPG::Cache.icon(icon)
  1602.         width = bitmap.width
  1603.         height = bitmap.height
  1604.         src_rect = Rect.new(0, 0, width, height)
  1605.         dest_rect = Rect.new(0, 24, width * 2, height * 2)
  1606.         self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  1607.       else
  1608.         width = 0
  1609.       end
  1610.       self.contents.font.color = normal_color
  1611.       self.contents.draw_text(4 + width * 2, 32, self.width - 40, 32, text, align)
  1612.       @text = text
  1613.       @align = align
  1614.       @actor = nil
  1615.     end
  1616.     self.visible = true
  1617.   end
  1618.   #--------------------------------------------------------------------------
  1619.   # * Set Actor
  1620.   #     actor : status displaying actor
  1621.   #--------------------------------------------------------------------------
  1622.   def set_actor(actor)
  1623.     if actor != @actor
  1624.       self.contents.clear
  1625.       draw_actor_name(actor, 4, 0)
  1626.       draw_actor_state(actor, 140, 0)
  1627.       draw_actor_hp(actor, 284, 0)
  1628.       draw_actor_sp(actor, 460, 0)
  1629.       @actor = actor
  1630.       @text = nil
  1631.       self.visible = true
  1632.     end
  1633.   end
  1634.   #--------------------------------------------------------------------------
  1635.   # * Set Enemy
  1636.   #     enemy : name and status displaying enemy
  1637.   #--------------------------------------------------------------------------
  1638.   def set_enemy(enemy)
  1639.     text = enemy.name
  1640.     state_text = make_battler_state_text(enemy, 112, false)
  1641.     if state_text != ""
  1642.       text += "  " + state_text
  1643.     end
  1644.     set_text(text, 1, 1)
  1645.   end
  1646. end
  1647.  
  1648. #==============================================================================
  1649. # ** Window_Status
  1650. #------------------------------------------------------------------------------
  1651. #  This window displays full status specs on the status screen.
  1652. #==============================================================================
  1653.  
  1654. class Window_Status < Window_Base
  1655.   #--------------------------------------------------------------------------
  1656.   # * include the CMS_Config module
  1657.   #--------------------------------------------------------------------------
  1658.   include CMS_Config
  1659.  
  1660.   #--------------------------------------------------------------------------
  1661.   # * Object Initialization
  1662.   #     actor : actor
  1663.   #--------------------------------------------------------------------------
  1664.   def initialize(actor)
  1665.     super(0, 0, 640, 480)
  1666.     self.contents = Bitmap.new(width - 32, height - 32)
  1667.     @actor = actor
  1668.     refresh
  1669.   end
  1670.   #--------------------------------------------------------------------------
  1671.   # * Refresh
  1672.   #--------------------------------------------------------------------------
  1673.   def refresh
  1674.     self.contents.clear
  1675.     self.contents.fill_rect(0, 28, 320, 392, normal_color)
  1676.     self.contents.fill_rect(1, 29, 318, 390, Color.new(0, 0, 0, 0))
  1677.     face = RPG::Cache.picture("Faces/" + $change_face.face(@actor.id))
  1678.     src_rect = Rect.new(0, 0, face.width, face.height)
  1679.     self.contents.blt(240 - face.width/2, 32, face, src_rect)
  1680.    
  1681.     # Draw the battler
  1682.     battler = RPG::Cache.battler(@actor.battler_name, @actor.battler_hue)
  1683.     src_rect = Rect.new(0, 0, battler.width, battler.height)
  1684.     if LARGE_BATTLER
  1685.       dest_rect = Rect.new(464 - battler.width, 224 - battler.height, battler.width*2, battler.height*2)
  1686.       self.contents.stretch_blt(dest_rect, battler, src_rect)
  1687.     else
  1688.       self.contents.blt(464 - battler.width/2, 224 - battler.height/2, battler, src_rect)
  1689.     end
  1690.     draw_actor_name(@actor, 12, 32)
  1691.     draw_actor_class(@actor, 12, 56)
  1692.     draw_actor_level(@actor, 96, 56)
  1693.     draw_actor_state(@actor, 48, 80)
  1694.     draw_actor_hp(@actor, 4, 160, 158)
  1695.     draw_actor_sp(@actor, 162, 160, 158)
  1696.     draw_actor_parameter(@actor, 4, 192, 0)
  1697.     draw_actor_parameter(@actor, 162, 192, 1)
  1698.     draw_actor_parameter(@actor, 4, 224, 2)
  1699.     draw_actor_parameter(@actor, 4, 256, 3)
  1700.     draw_actor_parameter(@actor, 4, 288, 5)
  1701.     draw_actor_parameter(@actor, 162, 256, 4)
  1702.     draw_actor_parameter(@actor, 162, 288, 6)
  1703.     self.contents.font.color = system_color
  1704.     self.contents.draw_text(160, 128, 60, 32, "EXP")
  1705.     self.contents.draw_text(4, 128, 60, 32, "NEXT")
  1706.     self.contents.font.color = normal_color
  1707.     self.contents.draw_text(220, 128, 84, 32, @actor.exp_s, 2)
  1708.     self.contents.draw_text(64, 128, 84, 32, @actor.next_rest_exp_s, 2)
  1709.     self.contents.font.color = system_color
  1710.     self.contents.font.size = 32
  1711.     self.contents.draw_text(0, 0, 160, 32, "Status")
  1712.     self.contents.font.size = 24
  1713.     draw_item_name($data_weapons[@actor.weapon_id], 4, 320)
  1714.     draw_item_name($data_armors[@actor.armor1_id], 160, 320)
  1715.     draw_item_name($data_armors[@actor.armor2_id], 4, 356)
  1716.     draw_item_name($data_armors[@actor.armor3_id], 160, 356)
  1717.     draw_item_name($data_armors[@actor.armor4_id], 80, 388)
  1718.    
  1719.     element = RPG::Cache.icon(ELEMENT_ICON[@actor.id])
  1720.     src_rect = Rect.new(0, 0, 24, 24)
  1721.     self.contents.blt(132, 32, element, src_rect)
  1722.    
  1723.     # Draw the hp and sp bars
  1724.       # Initialize the image variables
  1725.       bar_back = RPG::Cache.picture(SM_BARBACK)
  1726.       hp_bar = RPG::Cache.picture(SM_HPBAR)
  1727.       sp_bar = RPG::Cache.picture(SM_SPBAR)
  1728.  
  1729.       # Bar background
  1730.       width = bar_back.width
  1731.       height = bar_back.height
  1732.       src_rect = Rect.new(0, 0, width, height)
  1733.       self.contents.blt(4, 184, bar_back, src_rect)
  1734.       self.contents.blt(162, 184, bar_back, src_rect)
  1735.       # Heath bar
  1736.       width = hp_bar.width * @actor.hp / @actor.maxhp
  1737.       height = hp_bar.height
  1738.       src_rect = Rect.new(0, 0, width, height)
  1739.       self.contents.blt(4, 184, hp_bar, src_rect)
  1740.       # Magic bar
  1741.       width = sp_bar.width * @actor.sp / @actor.maxsp
  1742.       height = sp_bar.height
  1743.       src_rect = Rect.new(0, 0, width, height)
  1744.       self.contents.blt(162, 184, sp_bar, src_rect)
  1745.   end
  1746.   #--------------------------------------------------------------------------
  1747.   # * Draw Parameter
  1748.   #     actor : actor
  1749.   #     x     : draw spot x-coordinate
  1750.   #     y     : draw spot y-coordinate
  1751.   #     type  : parameter type (0-6)
  1752.   #--------------------------------------------------------------------------
  1753.   def draw_actor_parameter(actor, x, y, type)
  1754.     case type
  1755.     when 0
  1756.       parameter_name = $data_system.words.atk
  1757.       parameter_value = actor.atk
  1758.     when 1
  1759.       parameter_name = $data_system.words.pdef
  1760.       parameter_value = actor.pdef
  1761.     when 2
  1762.       parameter_name = $data_system.words.mdef
  1763.       parameter_value = actor.mdef
  1764.     when 3
  1765.       parameter_name = $data_system.words.str
  1766.       parameter_value = actor.str
  1767.     when 4
  1768.       parameter_name = $data_system.words.dex
  1769.       parameter_value = actor.dex
  1770.     when 5
  1771.       parameter_name = $data_system.words.agi
  1772.       parameter_value = actor.agi
  1773.     when 6
  1774.       parameter_name = $data_system.words.int
  1775.       parameter_value = actor.int
  1776.     end
  1777.     self.contents.font.color = system_color
  1778.     self.contents.draw_text(x, y, 80, 32, parameter_name)
  1779.     self.contents.font.color = normal_color
  1780.     self.contents.draw_text(x + 80, y, 36, 32, parameter_value.to_s, 2)
  1781.   end
  1782. end
  1783.  
  1784. #==============================================================================
  1785. # ** Scene_Menu
  1786. #------------------------------------------------------------------------------
  1787. #  This class performs menu screen processing.
  1788. #==============================================================================
  1789.  
  1790. class Scene_Menu
  1791.   #--------------------------------------------------------------------------
  1792.   # * include the CMS_Config module
  1793.   #--------------------------------------------------------------------------
  1794.   include CMS_Config
  1795.  
  1796.   # Object Initilization
  1797.   def initialize(menu_index = 0)
  1798.     @menu_index = menu_index
  1799.   end
  1800.   #
  1801.   # Main processing
  1802.   #
  1803.   def main
  1804.     #Set background to map
  1805.     if BG_MAP == true
  1806.       @spritesetmap = Spriteset_Map.new
  1807.     end
  1808.     # Make command window
  1809.     @command_window = Window_MenuCommand.new
  1810.     @command_window.index = @menu_index
  1811.     if $game_party.actors.size == 0
  1812.       for i in 0..COMMAND_SETUP.size
  1813.         @command_window.disable_item(i)
  1814.       end
  1815.     end
  1816.    
  1817.     # If there are no party members
  1818.     if $game_party.actors.size == 0
  1819.       # Disable items, skills, equipment, and status
  1820.       @command_window.disable_item(0)
  1821.       @command_window.disable_item(1)
  1822.       @command_window.disable_item(2)
  1823.       @command_window.disable_item(3)
  1824.     end
  1825.    
  1826.     # Manage BGM
  1827.     $game_system.bgm_memorize
  1828.     Audio.bgm_play("Audio/BGM/" + MENU_BGM[0], MENU_BGM[1], MENU_BGM[2]) if MENU_BGM[0] != ""
  1829.    
  1830.     #Draw windows
  1831.     @location_window = Window_Location.new
  1832.     @playtime_window = Window_PlayTime.new
  1833.     @gold_window = Window_Gold.new
  1834.     @status_window = Window_MenuStatus.new
  1835.    
  1836.     #Draw system window, make it invisible
  1837.     s1 = "Save"
  1838.     s2 = "Load"
  1839.     s3 = "Return To Title"
  1840.     s4 = "Shutdown"
  1841.     @system_window = Window_Command.new(172, [s1, s2, s3, s4])
  1842.     @system_window.x = 160
  1843.     @system_window.y = 288
  1844.     @system_window.z = 210
  1845.     @system_window.visible = false
  1846.     @system_window.active = false
  1847.    
  1848.     #Check for visibility, then make them visible
  1849.     @playtime_window.visible = TIME_WINDOW[0]
  1850.     @location_window.visible = LOCATION_WINDOW[0]
  1851.     @gold_window.visible = GOLD_WINDOW[0]
  1852.    
  1853.     # Animate Windows If Animation is ON   
  1854.     if ANIMATION == true
  1855.       case COMMAND_WINDOW[4]
  1856.       when "Up"
  1857.         @command_window.y = 480 + COMMAND_WINDOW[2]
  1858.       when "Down"
  1859.         @command_window.y = -COMMAND_WINDOW[2]
  1860.       when "Left"
  1861.         @command_window.x = 640 + COMMAND_WINDOW[1]
  1862.       when "Right"
  1863.         @command_window.x = -COMMAND_WINDOW[1].to_f
  1864.       end
  1865.       case TIME_WINDOW[4]
  1866.       when "Up"
  1867.         @playtime_window.y = 480 + TIME_WINDOW[2]
  1868.       when "Down"
  1869.         @playtime_window.y = -480 - TIME_WINDOW[2]
  1870.       when "Left"
  1871.         @playtime_window.x = 640 + TIME_WINDOW[1]
  1872.       when "Right"
  1873.         @playtime_window.x = -640 - TIME_WINDOW[1]
  1874.       end
  1875.       case LOCATION_WINDOW[4]
  1876.       when "Up"
  1877.         @location_window.y = 480 + LOCATION_WINDOW[2]
  1878.       when "Down"
  1879.         @location_window.y = -LOCATION_WINDOW[2]
  1880.       when "Left"
  1881.         @location_window.x = 640 + LOCATION_WINDOW[1]
  1882.       when "Right"
  1883.         @location_window.x = -LOCATION_WINDOW[1].to_f
  1884.       end
  1885.       case GOLD_WINDOW[4]
  1886.       when "Up"
  1887.         @gold_window.y = 480 + GOLD_WINDOW[2]
  1888.       when "Down"
  1889.         @gold_window.y = -480 - GOLD_WINDOW[2]
  1890.       when "Left"
  1891.         @gold_window.x = 640 + GOLD_WINDOW[1]
  1892.       when "Right"
  1893.         @gold_window.x = -640 - GOLD_WINDOW[1]
  1894.       end      
  1895.       case STATUS_WINDOW[3]
  1896.       when "Up"
  1897.         @status_window.y = 480 + STATUS_WINDOW[1]
  1898.       when "Down"
  1899.         @status_window.y = -480 - STATUS_WINDOW[1]
  1900.       when "Left"
  1901.         @status_window.x = 640 + STATUS_WINDOW[0]
  1902.       when "Right"
  1903.         @status_window.x = -640 - STATUS_WINDOW[0]
  1904.       end
  1905.     end
  1906.    
  1907.     # Execute Transition
  1908.     Graphics.transition
  1909.    
  1910.     # Main loop
  1911.     loop do
  1912.       # Update game screen
  1913.       Graphics.update
  1914.       # Update input info
  1915.       Input.update
  1916.       # Frame update
  1917.       update
  1918.       # Exit loop if screen is changed
  1919.       if $scene != self
  1920.         break
  1921.       end
  1922.     end
  1923.     # Prepare for transition
  1924.     Graphics.freeze
  1925.     # Dispose windows
  1926.     dispose
  1927.   end
  1928.  
  1929.   # Define window disposal
  1930.   def dispose
  1931.     if BG_MAP == true
  1932.       @spritesetmap.dispose
  1933.     end
  1934.     @command_window.dispose
  1935.     @location_window.dispose
  1936.     @playtime_window.dispose
  1937.     @gold_window.dispose
  1938.     @status_window.dispose
  1939.     @system_window.dispose
  1940.   end
  1941.  
  1942.   # Animation delay
  1943.   def delay(seconds)
  1944.     for i in 0...(seconds * 1)
  1945.       sleep 0.01
  1946.       Graphics.update
  1947.     end
  1948.   end
  1949.  
  1950.   # Frame Update
  1951.   def update
  1952.     windows_update
  1953.     if @system_window.active
  1954.        update_system
  1955.        return
  1956.     end
  1957.     if ANIMATION == true
  1958.       animate_window
  1959.     end
  1960.     if @command_window.active
  1961.       update_command
  1962.       return
  1963.     end
  1964.     if @status_window.active
  1965.       update_status
  1966.       return
  1967.     end
  1968.    
  1969.   end
  1970.  
  1971.   # How menu windows are updated
  1972.   def windows_update
  1973.     @command_window.update
  1974.     @location_window.update
  1975.     @playtime_window.update
  1976.     @gold_window.update
  1977.     @status_window.update
  1978.     @system_window.update
  1979.   end
  1980.  
  1981.   # How windows are animated
  1982.   def animate_window
  1983.     case COMMAND_WINDOW[4]
  1984.     when "Up"
  1985.       if @command_window.y > COMMAND_WINDOW[2]
  1986.         @command_window.y -= ((480 + COMMAND_WINDOW[2]) / 10).to_f
  1987.       end
  1988.       if @command_window.y < COMMAND_WINDOW[2]
  1989.         @command_window.y = COMMAND_WINDOW[2]
  1990.       end
  1991.     when "Down"
  1992.       if @command_window.y < COMMAND_WINDOW[2]
  1993.         @command_window.y += (COMMAND_WINDOW[2] / 10).to_f
  1994.       end
  1995.       if @command_window.y > COMMAND_WINDOW[2]
  1996.         @command_window.y = COMMAND_WINDOW[2]
  1997.       end
  1998.     when "Left"
  1999.       if @command_window.x > COMMAND_WINDOW[1]
  2000.         @command_window.x -= ((640 + COMMAND_WINDOW[1]) / 10).to_f
  2001.       end
  2002.       if @command_window.x < COMMAND_WINDOW[1]
  2003.         @command_window.x = COMMAND_WINDOW[1]
  2004.       end
  2005.     when "Right"
  2006.       if @command_window.x < COMMAND_WINDOW[1]
  2007.         @command_window.x += (COMMAND_WINDOW[1] / 10).to_f
  2008.       end
  2009.       if @command_window.x > COMMAND_WINDOW[1]
  2010.         @command_window.x= COMMAND_WINDOW[1]
  2011.       end
  2012.     end
  2013.    
  2014.     case TIME_WINDOW[4]
  2015.     when "Up"
  2016.       if @playtime_window.y > TIME_WINDOW[2]
  2017.         @playtime_window.y -= ((480 + TIME_WINDOW[2]) / 10).to_f
  2018.       end
  2019.       if @playtime_window.y < TIME_WINDOW[2]
  2020.         @playtime_window.y = TIME_WINDOW[2]
  2021.       end
  2022.     when "Down"
  2023.       if @playtime_window.y < TIME_WINDOW[2]
  2024.         @playtime_window.y += ((480 + TIME_WINDOW[2]) / 10).to_f
  2025.       end
  2026.       if @playtime_window.y > TIME_WINDOW[2]
  2027.         @playtime_window.y = TIME_WINDOW[2]
  2028.       end
  2029.     when "Left"
  2030.       if @playtime_window.x > TIME_WINDOW[1]
  2031.         @playtime_window.x -= ((640 + TIME_WINDOW[1]) / 10).to_f
  2032.       end
  2033.       if @playtime_window.x < TIME_WINDOW[1]
  2034.         @playtime_window.x = TIME_WINDOW[1]
  2035.       end
  2036.     when "Right"
  2037.       if @playtime_window.x < TIME_WINDOW[1]
  2038.         @playtime_window.x += ((640 + TIME_WINDOW[1]) / 10).to_f
  2039.       end
  2040.       if @playtime_window.x > TIME_WINDOW[1]
  2041.         @playtime_window.x = TIME_WINDOW[1]
  2042.       end
  2043.     end
  2044.    
  2045.     case LOCATION_WINDOW[4]
  2046.     when "Up"
  2047.       if @location_window.y > LOCATION_WINDOW[2]
  2048.         @location_window.y -= ((480 + LOCATION_WINDOW[2]) / 10).to_f
  2049.       end
  2050.       if @location_window.y < LOCATION_WINDOW[2]
  2051.         @location_window.y = LOCATION_WINDOW[2]
  2052.       end
  2053.     when "Down"
  2054.       if @location_window.y < LOCATION_WINDOW[2]
  2055.         @location_window.y += (LOCATION_WINDOW[2] / 10).to_f
  2056.       end
  2057.       if @location_window.y > LOCATION_WINDOW[2]
  2058.         @location_window.y = LOCATION_WINDOW[2]
  2059.       end
  2060.     when "Left"
  2061.       if @location_window.x > LOCATION_WINDOW[1]
  2062.         @location_window.x -= ((640 + LOCATION_WINDOW[1]) / 10).to_f
  2063.       end
  2064.       if @location_window.x < LOCATION_WINDOW[1]
  2065.         @location_window.x = LOCATION_WINDOW[1]
  2066.       end
  2067.     when "Right"
  2068.       if @location_window.x < LOCATION_WINDOW[1]
  2069.         @location_window.x += (LOCATION_WINDOW[1] / 10).to_f
  2070.       end
  2071.       if @location_window.x > LOCATION_WINDOW[1]
  2072.         @location_window.x= LOCATION_WINDOW[1]
  2073.       end
  2074.     end
  2075.  
  2076.     case GOLD_WINDOW[4]
  2077.     when "Up"
  2078.       if @gold_window.y > GOLD_WINDOW[2]
  2079.         @gold_window.y -= ((480 + GOLD_WINDOW[2]) / 10).to_f
  2080.       end
  2081.       if @gold_window.y < GOLD_WINDOW[2]
  2082.         @gold_window.y = GOLD_WINDOW[2]
  2083.       end
  2084.     when "Down"
  2085.       if @gold_window.y < GOLD_WINDOW[2]
  2086.         @gold_window.y += ((480 + GOLD_WINDOW[2]) / 10).to_f
  2087.       end
  2088.       if @gold_window.y > GOLD_WINDOW[2]
  2089.         @gold_window.y = GOLD_WINDOW[2]
  2090.       end
  2091.     when "Left"
  2092.       if @gold_window.x > GOLD_WINDOW[1]
  2093.         @gold_window.x -= ((640 + GOLD_WINDOW[1]) / 10).to_f
  2094.       end
  2095.       if @gold_window.x < GOLD_WINDOW[1]
  2096.         @gold_window.x = GOLD_WINDOW[1]
  2097.       end
  2098.     when "Right"
  2099.       if @gold_window.x < GOLD_WINDOW[1]
  2100.         @gold_window.x += ((640 + GOLD_WINDOW[1]) / 10).to_f
  2101.       end
  2102.       if @gold_window.x > GOLD_WINDOW[1]
  2103.         @gold_window.x = GOLD_WINDOW[1]
  2104.       end
  2105.     end
  2106.    
  2107.     case STATUS_WINDOW[3]
  2108.     when "Up"
  2109.       if @status_window.y > STATUS_WINDOW[1]
  2110.         @status_window.y -= ((480 + STATUS_WINDOW[1]) / 10).to_f
  2111.       end
  2112.       if @status_window.y < STATUS_WINDOW[1]
  2113.         @status_window.y = STATUS_WINDOW[1]
  2114.       end
  2115.     when "Down"
  2116.       if @status_window.y < STATUS_WINDOW[1]
  2117.         @status_window.y += ((480 + STATUS_WINDOW[1]) / 10).to_f
  2118.       end
  2119.       if @status_window.y > STATUS_WINDOW[1]
  2120.         @status_window.y = STATUS_WINDOW[1]
  2121.       end
  2122.     when "Left"
  2123.       if @status_window.x > STATUS_WINDOW[1]
  2124.         @status_window.x -= ((640 + STATUS_WINDOW[1]) / 10).to_f
  2125.       end
  2126.       if @status_window.x < STATUS_WINDOW[1]
  2127.         @status_window.x = STATUS_WINDOW[1]
  2128.       end
  2129.     when "Right"
  2130.       if @status_window.x < STATUS_WINDOW[1]
  2131.         @status_window.x += ((640 + STATUS_WINDOW[1]) / 10).to_f
  2132.       end
  2133.       if @status_window.x > STATUS_WINDOW[1]
  2134.         @status_window.x = STATUS_WINDOW[1]
  2135.       end
  2136.     end
  2137.  
  2138.   end  
  2139.  
  2140.   # Window animation for menu exit
  2141.   def delete_window
  2142.     i=0
  2143.     loop do
  2144.       windows_update
  2145.       case COMMAND_WINDOW[4]
  2146.       when "Up"
  2147.         if @command_window.y < 480 + COMMAND_WINDOW[2]
  2148.           @command_window.y += ((480 + COMMAND_WINDOW[2]) / 10).to_f
  2149.         end
  2150.       when "Down"
  2151.         if @command_window.y > -480 - COMMAND_WINDOW[2]
  2152.           @command_window.y -= ((480 + COMMAND_WINDOW[2]) / 10).to_f
  2153.         end
  2154.       when "Left"
  2155.         if @command_window.x < 640 + COMMAND_WINDOW[1]
  2156.           @command_window.x += ((640 + COMMAND_WINDOW[1]) / 10).to_f
  2157.         end
  2158.       when "Right"
  2159.         if @command_window.x > -640 - COMMAND_WINDOW[1]
  2160.           @command_window.x -= ((640 + COMMAND_WINDOW[1]) / 10).to_f
  2161.         end
  2162.       end
  2163.      
  2164.       case LOCATION_WINDOW[4]
  2165.       when "Up"
  2166.         if @location_window.y < 480 + LOCATION_WINDOW[2]
  2167.           @location_window.y += ((480 + LOCATION_WINDOW[2]) / 10).to_f
  2168.         end
  2169.       when "Down"
  2170.         if @location_window.y > -480 - LOCATION_WINDOW[2]
  2171.           @location_window.y -= ((480 + LOCATION_WINDOW[2]) / 10).to_f
  2172.         end
  2173.       when "Left"
  2174.         if @location_window.x < 640 + LOCATION_WINDOW[1]
  2175.           @location_window.x += ((640 + LOCATION_WINDOW[1]) / 10).to_f
  2176.         end
  2177.       when "Right"
  2178.         if @location_window.x > -640 - LOCATION_WINDOW[1]
  2179.           @location_window.x -= ((640 + LOCATION_WINDOW[1]) / 10).to_f
  2180.         end
  2181.       end
  2182.      
  2183.       case TIME_WINDOW[4]
  2184.       when "Up"
  2185.         if @playtime_window.y < 480 + TIME_WINDOW[2]
  2186.           @playtime_window.y += ((480 + TIME_WINDOW[2]) / 10).to_f
  2187.         end
  2188.       when "Down"
  2189.         if @playtime_window.y > -480 - TIME_WINDOW[2]
  2190.           @playtime_window.y -= ((480 + TIME_WINDOW[2]) / 10).to_f
  2191.         end
  2192.       when "Left"
  2193.         if @playtime_window.x < 640 + TIME_WINDOW[1]
  2194.           @playtime_window.x += ((640 + TIME_WINDOW[1]) / 10).to_f
  2195.         end
  2196.       when "Right"
  2197.         if @playtime_window.x > -640 - TIME_WINDOW[1]
  2198.           @playtime_window.x -= ((640 + TIME_WINDOW[1]) / 10).to_f
  2199.         end
  2200.       end
  2201.        
  2202.       case GOLD_WINDOW[4]
  2203.       when "Up"
  2204.         if @gold_window.y < 480 + GOLD_WINDOW[2]
  2205.           @gold_window.y += ((480 + GOLD_WINDOW[2]) / 10).to_f
  2206.         end
  2207.       when "Down"
  2208.         if @gold_window.y > -480 - GOLD_WINDOW[2]
  2209.           @gold_window.y -= ((480 + GOLD_WINDOW[2]) / 10).to_f
  2210.         end
  2211.       when "Left"
  2212.         if @gold_window.x < 640 + GOLD_WINDOW[1]
  2213.           @gold_window.x += ((640 + GOLD_WINDOW[1]) / 10).to_f
  2214.         end
  2215.       when "Right"
  2216.         if @gold_window.x > -640 - GOLD_WINDOW[1]
  2217.           @gold_window.x -= ((640 + GOLD_WINDOW[1]) / 10).to_f
  2218.         end
  2219.       end
  2220.      
  2221.       case STATUS_WINDOW[3]
  2222.       when "Up"
  2223.         if @status_window.y < 480 + STATUS_WINDOW[1]
  2224.           @status_window.y += ((480 + STATUS_WINDOW[1]) / 10).to_f
  2225.         end
  2226.       when "Down"
  2227.         if @status_window.y > -480 - STATUS_WINDOW[1]
  2228.           @status_window.y -= ((480 + STATUS_WINDOW[1]) / 10).to_f
  2229.         end
  2230.       when "Left"
  2231.         if @status_window.x < 640 + STATUS_WINDOW[0]
  2232.           @status_window.x += ((640 + STATUS_WINDOW[0]) / 10).to_f
  2233.         end
  2234.       when "Right"
  2235.         if @status_window.x > -640 - STATUS_WINDOW[0]
  2236.           @status_window.x -= ((640 + STATUS_WINDOW[0]) / 10).to_f
  2237.         end
  2238.       end
  2239.      
  2240.       delay(1)
  2241.       i += 1
  2242.       if i == 10
  2243.         break
  2244.       end
  2245.     end
  2246.   end
  2247.  
  2248.   # How commands are updated
  2249.   def update_command
  2250.     if Input.trigger?(Input::B)
  2251.       $game_system.se_play($data_system.cancel_se)
  2252.       delete_window if ANIMATION
  2253.       $game_system.bgm_restore
  2254.       $scene = Scene_Map.new
  2255.       return
  2256.     end
  2257.     if Input.trigger?(Input::C)
  2258.       if $game_party.actors.size == 0 and @command_window.index < 4
  2259.         $game_system.se_play($data_system.buzzer_se)
  2260.         return
  2261.       end
  2262.       # Branch by command window cursor position
  2263.       case @command_window.index
  2264.       when 0 #items
  2265.         # Play decision SE
  2266.         $game_system.se_play($data_system.decision_se)
  2267.         # Switch to item screen
  2268.         $scene = Scene_Item.new
  2269.       when 1 #skills
  2270.         # Play decision SE
  2271.         $game_system.se_play($data_system.decision_se)
  2272.         # Make status window active
  2273.         @command_window.active = false
  2274.         @status_window.active = true
  2275.         @status_window.index = 0
  2276.       when 2 #equipment
  2277.         # Play decision SE
  2278.         $game_system.se_play($data_system.decision_se)
  2279.         # Make status window active
  2280.         @command_window.active = false
  2281.         @status_window.active = true
  2282.         @status_window.index = 0
  2283.       when 3 #status
  2284.         # Play decision SE
  2285.         $game_system.se_play($data_system.decision_se)
  2286.         # Make status window active
  2287.         @command_window.active = false
  2288.         @status_window.active = true
  2289.         @status_window.index = 0
  2290.       when 4 #beastiary
  2291.         # Play decision SE
  2292.         $game_system.se_play($data_system.decision_se)
  2293.         # Switch to monster book screen
  2294.         $scene = Scene_Bestiary.new
  2295.       when 5 #system
  2296.         # Play decision SE
  2297.         $game_system.se_play($data_system.decision_se)
  2298.         @command_window.active = false
  2299.         @system_window.visible = true
  2300.         @system_window.active = true
  2301.       end
  2302.       return
  2303.     end
  2304.   end
  2305.  
  2306.   #--------------------------------------------------------------------------
  2307.   # * Frame Update (when status window is active)
  2308.   #--------------------------------------------------------------------------
  2309.   def update_status
  2310.     if Input.trigger?(Input::B)
  2311.       $game_system.se_play($data_system.cancel_se)
  2312.       @command_window.active = true
  2313.       @status_window.active = false
  2314.       @status_window.index = -1
  2315.       return
  2316.     end
  2317.     if Input.trigger?(Input::C)
  2318.       case @command_window.index
  2319.       when 1
  2320.         if $game_party.actors[@status_window.index].restriction >= 2
  2321.           $game_system.se_play($data_system.buzzer_se)
  2322.           return
  2323.         end
  2324.         $game_system.se_play($data_system.decision_se)
  2325.         $scene = Scene_Skill.new(@status_window.index)
  2326.       when 2
  2327.         $game_system.se_play($data_system.decision_se)
  2328.         $scene = Scene_Equip.new(@status_window.index)
  2329.       when 3
  2330.         $game_system.se_play($data_system.decision_se)
  2331.         $scene = Scene_Status.new(@status_window.index)
  2332.       end
  2333.       return
  2334.     end
  2335.   end
  2336.   #--------------------------------------------------------------------------
  2337.   # * Frame Update (when system window is active)
  2338.   #--------------------------------------------------------------------------
  2339.   def update_system
  2340.     # If B button was pressed
  2341.     if Input.trigger?(Input::B)
  2342.       # Play cancel SE
  2343.       $game_system.se_play($data_system.cancel_se)
  2344.       # Make command window active
  2345.       @command_window.active = true
  2346.       @system_window.active = false
  2347.       @system_window.visible = false
  2348.       @system_window.index = 0
  2349.       return
  2350.     end
  2351.     # If C button was pressed
  2352.     if Input.trigger?(Input::C)
  2353.       # Branch by command window cursor position
  2354.       case @system_window.index
  2355.       when 0  # save
  2356.         # If saving is forbidden
  2357.         if $game_system.save_disabled
  2358.           # Play buzzer SE
  2359.           $game_system.se_play($data_system.buzzer_se)
  2360.           return
  2361.         end
  2362.         # Play decision SE
  2363.         $game_system.se_play($data_system.decision_se)
  2364.         # Switch to save screen
  2365.         $scene = Scene_Save.new
  2366.       when 1  # load
  2367.         # Continue enabled determinant
  2368.         # Check if at least one save file exists
  2369.         # If enabled, make @continue_enabled true; if disabled, make it false
  2370.         @continue_enabled = false
  2371.         for i in 0..3
  2372.           if FileTest.exist?("Save#{i+1}.rxdata")
  2373.             @continue_enabled = true
  2374.           end
  2375.         end
  2376.         # If continue is disabled
  2377.         unless @continue_enabled
  2378.           # Play buzzer SE
  2379.           $game_system.se_play($data_system.buzzer_se)
  2380.           return
  2381.         end
  2382.         # Play decision SE
  2383.         $game_system.se_play($data_system.decision_se)
  2384.         #Switch to load screen
  2385.         $scene = Scene_MenuLoad.new
  2386.       when 2  # return to title
  2387.         $recent_items = []
  2388.         # Play decision SE
  2389.         $game_system.se_play($data_system.decision_se)
  2390.         # Fade out BGM, BGS, and ME
  2391.         Audio.bgm_fade(800)
  2392.         Audio.bgs_fade(800)
  2393.         Audio.me_fade(800)
  2394.         # Switch to title screen
  2395.         $scene = Scene_Title.new
  2396.       when 3  # shutdown
  2397.         # Play decision SE
  2398.         $game_system.se_play($data_system.decision_se)
  2399.         # Fade out BGM, BGS, and ME
  2400.         Audio.bgm_fade(800)
  2401.         Audio.bgs_fade(800)
  2402.         Audio.me_fade(800)
  2403.         # Shutdown
  2404.         $scene = nil
  2405.       end
  2406.       return
  2407.     end
  2408.   end
  2409.  
  2410. end
  2411.  
  2412. #==============================================================================
  2413. # ** Scene_Skill
  2414. #------------------------------------------------------------------------------
  2415. #  This class performs skill screen processing.
  2416. #==============================================================================
  2417.  
  2418. class Scene_Skill
  2419.   #--------------------------------------------------------------------------
  2420.   # * Object Initialization
  2421.   #     actor_index : actor index
  2422.   #--------------------------------------------------------------------------
  2423.   def initialize(actor_index = 0, equip_index = 0)
  2424.     @actor_index = actor_index
  2425.   end
  2426.   #--------------------------------------------------------------------------
  2427.   # * Main Processing
  2428.   #--------------------------------------------------------------------------
  2429.   def main
  2430.     # Get actor
  2431.     @actor = $game_party.actors[@actor_index]
  2432.     # Make help window, status window, and skill window
  2433.     @help_window = Window_Help.new
  2434.     @help_window.y = 416
  2435.     @status_window = Window_SkillStatus.new(@actor)
  2436.     @status_window.y = 0
  2437.     @skill_window = Window_Skill.new(@actor)
  2438.     @skill_window.y = 64
  2439.     # Associate help window
  2440.     @skill_window.help_window = @help_window
  2441.     # Make target window (set to invisible / inactive)
  2442.     @target_window = Window_TargetMenu.new
  2443.     @target_window.visible = false
  2444.     @target_window.active = false
  2445.     # Execute transition
  2446.     Graphics.transition
  2447.     # Main loop
  2448.     loop do
  2449.       # Update game screen
  2450.       Graphics.update
  2451.       # Update input information
  2452.       Input.update
  2453.       # Frame update
  2454.       update
  2455.       # Abort loop if screen is changed
  2456.       if $scene != self
  2457.         break
  2458.       end
  2459.     end
  2460.     # Prepare for transition
  2461.     Graphics.freeze
  2462.     # Dispose of windows
  2463.     @help_window.dispose
  2464.     @status_window.dispose
  2465.     @skill_window.dispose
  2466.     @target_window.dispose
  2467.   end
  2468.   #--------------------------------------------------------------------------
  2469.   # * Frame Update (if skill window is active)
  2470.   #--------------------------------------------------------------------------
  2471.   def update_skill
  2472.     # If B button was pressed
  2473.     if Input.trigger?(Input::B)
  2474.       # Play cancel SE
  2475.       $game_system.se_play($data_system.cancel_se)
  2476.       # Switch to menu screen
  2477.       $scene = Scene_Menu.new
  2478.       return
  2479.     end
  2480.     # If C button was pressed
  2481.     if Input.trigger?(Input::C)
  2482.       # Get currently selected data on the skill window
  2483.       @skill = @skill_window.skill
  2484.       # If unable to use
  2485.       if @skill == nil or not @actor.skill_can_use?(@skill.id)
  2486.         # Play buzzer SE
  2487.         $game_system.se_play($data_system.buzzer_se)
  2488.         return
  2489.       end
  2490.       # Play decision SE
  2491.       $game_system.se_play($data_system.decision_se)
  2492.       # If effect scope is ally
  2493.       if @skill.scope >= 3
  2494.         # Activate target window
  2495.         @skill_window.active = false
  2496.         @target_window.x = (@skill_window.index + 1) % 2 * 304
  2497.         @target_window.visible = true
  2498.         @target_window.active = true
  2499.         # Set cursor position to effect scope (single / all)
  2500.         if @skill.scope == 4 || @skill.scope == 6
  2501.           @target_window.index = -1
  2502.         elsif @skill.scope == 7
  2503.           @target_window.index = @actor_index - 10
  2504.         else
  2505.           @target_window.index = 0
  2506.         end
  2507.       # If effect scope is other than ally
  2508.       else
  2509.         # If common event ID is valid
  2510.         if @skill.common_event_id > 0
  2511.           # Common event call reservation
  2512.           $game_temp.common_event_id = @skill.common_event_id
  2513.           # Play use skill SE
  2514.           $game_system.se_play(@skill.menu_se)
  2515.           # Use up SP
  2516.           @actor.sp -= @skill.sp_cost
  2517.           # Remake each window content
  2518.           @status_window.refresh
  2519.           @skill_window.refresh
  2520.           @target_window.refresh
  2521.           # Switch to map screen
  2522.           $scene = Scene_Map.new
  2523.           return
  2524.         end
  2525.       end
  2526.       return
  2527.     end
  2528.     # If R button was pressed
  2529.     if Input.trigger?(Input::R)
  2530.       # Play cursor SE
  2531.       $game_system.se_play($data_system.cursor_se)
  2532.       # To next actor
  2533.       @actor_index += 1
  2534.       @actor_index %= $game_party.actors.size
  2535.       # Switch to different skill screen
  2536.       $scene = Scene_Skill.new(@actor_index)
  2537.       return
  2538.     end
  2539.     # If L button was pressed
  2540.     if Input.trigger?(Input::L)
  2541.       # Play cursor SE
  2542.       $game_system.se_play($data_system.cursor_se)
  2543.       # To previous actor
  2544.       @actor_index += $game_party.actors.size - 1
  2545.       @actor_index %= $game_party.actors.size
  2546.       # Switch to different skill screen
  2547.       $scene = Scene_Skill.new(@actor_index)
  2548.       return
  2549.     end
  2550.   end
  2551. end
  2552.  
  2553. #==============================================================================
  2554. # ** Scene_Item
  2555. #------------------------------------------------------------------------------
  2556. #  This class performs item screen processing.
  2557. #==============================================================================
  2558.  
  2559. class Scene_Item
  2560.   #--------------------------------------------------------------------------
  2561.   # * Main Processing
  2562.   #--------------------------------------------------------------------------
  2563.   def main
  2564.     # Make help window, item window
  2565.     @help_window = Window_ItemHelp.new
  2566.     @itemtop_window = Window_ItemTop.new
  2567.     @help_windowback = Window_Blank.new(0, 416, 640, 64)
  2568.     @help_window.y = 384
  2569.     @item_window = Window_ItemMenu.new
  2570.     @item_window.active = false
  2571.     # Associate help window
  2572.     @item_window.help_window = @help_window
  2573.     # Make target window (set to active)
  2574.     @category_window = Window_Category.new(440, ["1","2","3","4","5","6","7","8","9"])
  2575.     @category_window.active = true
  2576.     @category_window.help_window = @help_window
  2577.     # Execute transition
  2578.     # Make target window (set to invisible / inactive)
  2579.     @target_window = Window_TargetMenu.new
  2580.     @target_window.visible = false
  2581.     @target_window.active = false
  2582.     @item_window.repaint
  2583.     # Execute transition
  2584.     Graphics.transition
  2585.     # Main loop
  2586.     loop do
  2587.       # Update game screen
  2588.       Graphics.update
  2589.       # Update input information
  2590.       Input.update
  2591.       # Frame update
  2592.       update
  2593.       # Abort loop if screen is changed
  2594.       if $scene != self
  2595.         break
  2596.       end
  2597.     end
  2598.     # Prepare for transition
  2599.     Graphics.freeze
  2600.     # Dispose of windows
  2601.     @help_window.dispose
  2602.     @item_window.dispose
  2603.     @target_window.dispose
  2604.     @help_windowback.dispose
  2605.     @category_window.dispose
  2606.     @itemtop_window.dispose
  2607.   end
  2608.   #--------------------------------------------------------------------------
  2609.   # * Frame Update
  2610.   #--------------------------------------------------------------------------
  2611.   def update
  2612.     # Update windows
  2613.     @help_window.update
  2614.     @item_window.update
  2615.     @target_window.update
  2616.     @help_windowback.update
  2617.     @category_window.update
  2618.     @itemtop_window.update
  2619.     # If item window is active: call update_item
  2620.     if @item_window.active
  2621.       update_item
  2622.       return
  2623.     end
  2624.     # If target window is active: call update_target
  2625.     if @target_window.active
  2626.       update_target
  2627.       return
  2628.     end
  2629.     # If target window is active: call update_target
  2630.     if @category_window.active
  2631.       update_category
  2632.       return
  2633.     end
  2634.   end
  2635.   #--------------------------------------------------------------------------
  2636.   # * Frame Update (when item window is active)
  2637.   #--------------------------------------------------------------------------
  2638.   def update_item
  2639.     # If B button was pressed
  2640.     if Input.trigger?(Input::B)
  2641.       # Play cancel SE
  2642.       $game_system.se_play($data_system.cancel_se)
  2643.       # Switch to menu screen
  2644.       $scene = Scene_Menu.new(1)
  2645.       return
  2646.     end
  2647.     # If C button was pressed
  2648.     if Input.trigger?(Input::C)
  2649.       # Get currently selected data on the item window
  2650.       @item = @item_window.item
  2651.       # If not a use item
  2652.       unless @item.is_a?(RPG::Item)
  2653.         # Play buzzer SE
  2654.         $game_system.se_play($data_system.buzzer_se)
  2655.         return
  2656.       end
  2657.       # If it can't be used
  2658.       unless $game_party.item_can_use?(@item.id)
  2659.         # Play buzzer SE
  2660.         $game_system.se_play($data_system.buzzer_se)
  2661.         return
  2662.       end
  2663.       # Play decision SE
  2664.       $game_system.se_play($data_system.decision_se)
  2665.       # If effect scope is an ally
  2666.       if @item.scope >= 3
  2667.         # Activate target window
  2668.         @item_window.active = false
  2669.         @target_window.x = (@item_window.index + 1) % 2 * 304
  2670.         @target_window.visible = true
  2671.         @target_window.active = true
  2672.         # Set cursor position to effect scope (single / all)
  2673.         if @item.scope == 4 || @item.scope == 6
  2674.           @target_window.index = -1
  2675.         else
  2676.           @target_window.index = 0
  2677.         end
  2678.       # If effect scope is other than an ally
  2679.       else
  2680.         # If command event ID is valid
  2681.         if @item.common_event_id > 0
  2682.           # Command event call reservation
  2683.           $game_temp.common_event_id = @item.common_event_id
  2684.           # Play item use SE
  2685.           $game_system.se_play(@item.menu_se)
  2686.           # If consumable
  2687.           if @item.consumable
  2688.             # Decrease used items by 1
  2689.             $game_party.lose_item(@item.id, 1)
  2690.             # Draw item window item
  2691.             @item_window.draw_item(@item_window.index)
  2692.           end
  2693.           # Switch to map screen
  2694.           $scene = Scene_Map.new
  2695.           return
  2696.         end
  2697.       end
  2698.       return
  2699.     end
  2700.     # If UP button was pressed
  2701.     if Input.trigger?(Input::UP) && @item_window.index == -1
  2702.       # Set category window active
  2703.       @item_window.active = false
  2704.       @item_window.cat_select(true)
  2705.       @category_window.active = true
  2706.       #@item_window.index = 0
  2707.       # Play cursor SE
  2708.       $game_system.se_play($data_system.cursor_se)
  2709.       return
  2710.     end
  2711.   end
  2712.   #--------------------------------------------------------------------------
  2713.   # * Frame Update (when target window is active)
  2714.   #--------------------------------------------------------------------------
  2715.   def update_target
  2716.     # If B button was pressed
  2717.     if Input.trigger?(Input::B)
  2718.       # Play cancel SE
  2719.       $game_system.se_play($data_system.cancel_se)
  2720.       # If unable to use because items ran out
  2721.       unless $game_party.item_can_use?(@item.id)
  2722.         # Remake item window contents
  2723.         @item_window.refresh
  2724.       end
  2725.       # Erase target window
  2726.       @item_window.active = true
  2727.       @target_window.visible = false
  2728.       @target_window.active = false
  2729.       @item_window.repaint
  2730.       return
  2731.     end
  2732.     # If C button was pressed
  2733.     if Input.trigger?(Input::C)
  2734.       # If items are used up
  2735.       if $game_party.item_number(@item.id) == 0
  2736.         # Play buzzer SE
  2737.         $game_system.se_play($data_system.buzzer_se)
  2738.         return
  2739.       end
  2740.       # If target is all
  2741.       if @target_window.index == -1
  2742.         # Apply item effects to entire party
  2743.         used = false
  2744.         for i in $game_party.actors
  2745.           used |= i.item_effect(@item)
  2746.         end
  2747.       end
  2748.       # If single target
  2749.       if @target_window.index >= 0
  2750.         # Apply item use effects to target actor
  2751.         target = $game_party.actors[@target_window.index]
  2752.         used = target.item_effect(@item)
  2753.       end
  2754.       # If an item was used
  2755.       if used
  2756.         # Play item use SE
  2757.         $game_system.se_play(@item.menu_se)
  2758.         # If consumable
  2759.         if @item.consumable
  2760.           # Decrease used items by 1
  2761.           $game_party.lose_item(@item.id, 1)
  2762.           # Redraw item window item
  2763.           @item_window.draw_items(@item_window.index)
  2764.         end
  2765.         # Remake target window contents
  2766.         @target_window.refresh
  2767.         # If all party members are dead
  2768.         if $game_party.all_dead?
  2769.           # Switch to game over screen
  2770.           $scene = Scene_Gameover.new
  2771.           return
  2772.         end
  2773.         # If common event ID is valid
  2774.         if @item.common_event_id > 0
  2775.           # Common event call reservation
  2776.           $game_temp.common_event_id = @item.common_event_id
  2777.           # Switch to map screen
  2778.           $scene = Scene_Map.new
  2779.           return
  2780.         end
  2781.       end
  2782.       # If item wasn't used
  2783.       unless used
  2784.         # Play buzzer SE
  2785.         $game_system.se_play($data_system.buzzer_se)
  2786.       end
  2787.       return
  2788.     end
  2789.   end
  2790.   #--------------------------------------------------------------------------
  2791.   # * Frame Update (when category window is active)
  2792.   #--------------------------------------------------------------------------
  2793.   def update_category
  2794.     @item_window.category(@category_window.index)
  2795.     @item_window.cat_select(true)
  2796.     if Input.repeat?(Input::RIGHT) || Input.repeat?(Input::LEFT)
  2797.     @item_window.repaint
  2798.     end
  2799.     # If B button was pressed
  2800.     if Input.trigger?(Input::B)
  2801.       # Play cancel SE
  2802.       $game_system.se_play($data_system.cancel_se)
  2803.       # Switch to menu screen
  2804.       $scene = Scene_Menu.new(1)
  2805.       return
  2806.     end
  2807.     # If C button was pressed
  2808.     if Input.trigger?(Input::C)
  2809.       # Get currently selected data on the item window
  2810.       @item = @category_window.index
  2811.       # Play decision SE
  2812.       $game_system.se_play($data_system.decision_se)
  2813.       return
  2814.     end
  2815.     # If DOWN button was pressed
  2816.     if Input.trigger?(Input::DOWN)
  2817.       # Set item window active
  2818.       @item_window.active = true
  2819.       @item_window.index = 0
  2820.       @category_window.active = false
  2821.       @item_window.cat_select(false)
  2822.       # Play cursor SE
  2823.       $game_system.se_play($data_system.cursor_se)
  2824.       return
  2825.     end
  2826.   end
  2827. end
  2828.  
  2829. #==============================================================================
  2830. # ** Scene_Equip
  2831. #------------------------------------------------------------------------------
  2832. #  This class performs equipment screen processing.
  2833. #==============================================================================
  2834.  
  2835. class Scene_Equip
  2836.   #--------------------------------------------------------------------------
  2837.   # * Object Initialization
  2838.   #     actor_index : actor index
  2839.   #     equip_index : equipment index
  2840.   #--------------------------------------------------------------------------
  2841.   def initialize(actor_index = 0, equip_index = 0)
  2842.     @actor_index = actor_index
  2843.     @equip_index = equip_index
  2844.   end
  2845.   #--------------------------------------------------------------------------
  2846.   # * Main Processing
  2847.   #--------------------------------------------------------------------------
  2848.   def main
  2849.     # Get actor
  2850.     @actor = $game_party.actors[@actor_index]
  2851.     # Make windows
  2852.     @help_window = Window_EquipHelp.new
  2853.     @status_window = Window_EquipStatus.new(@actor)
  2854.     @right_window = Window_EquipRight.new(@actor)
  2855.     @left_window = Window_EquipLeft.new(@actor)
  2856.     @left_window.z = 210
  2857.     @left_window.visible = false
  2858.     @item_window1 = Window_EquipItem.new(@actor, 0)
  2859.     @item_window2 = Window_EquipItem.new(@actor, 1)
  2860.     @item_window3 = Window_EquipItem.new(@actor, 2)
  2861.     @item_window4 = Window_EquipItem.new(@actor, 3)
  2862.     @item_window5 = Window_EquipItem.new(@actor, 4)
  2863.     # Associate help window
  2864.     @right_window.help_window = @help_window
  2865.     @item_window1.help_window = @help_window
  2866.     @item_window2.help_window = @help_window
  2867.     @item_window3.help_window = @help_window
  2868.     @item_window4.help_window = @help_window
  2869.     @item_window5.help_window = @help_window
  2870.     # Set cursor position
  2871.     @right_window.index = @equip_index
  2872.     refresh
  2873.     # Execute transition
  2874.     Graphics.transition
  2875.     # Main loop
  2876.     loop do
  2877.       # Update game screen
  2878.       Graphics.update
  2879.       # Update input information
  2880.       Input.update
  2881.       # Frame update
  2882.       update
  2883.       # Abort loop if screen is changed
  2884.       if $scene != self
  2885.         break
  2886.       end
  2887.     end
  2888.     # Prepare for transition
  2889.     Graphics.freeze
  2890.     # Dispose of windows
  2891.     @help_window.dispose
  2892.     @status_window.dispose
  2893.     @left_window.dispose
  2894.     @right_window.dispose
  2895.     @item_window1.dispose
  2896.     @item_window2.dispose
  2897.     @item_window3.dispose
  2898.     @item_window4.dispose
  2899.     @item_window5.dispose
  2900.   end
  2901.   #--------------------------------------------------------------------------
  2902.   # * Refresh
  2903.   #--------------------------------------------------------------------------
  2904.   def refresh
  2905.     # Set item window to visible
  2906.     @item_window1.visible = (@right_window.index == 0)
  2907.     @item_window2.visible = (@right_window.index == 1)
  2908.     @item_window3.visible = (@right_window.index == 2)
  2909.     @item_window4.visible = (@right_window.index == 3)
  2910.     @item_window5.visible = (@right_window.index == 4)
  2911.     # Get currently equipped item
  2912.     item1 = @right_window.item
  2913.     # Set current item window to @item_window
  2914.     case @right_window.index
  2915.     when 0
  2916.       @item_window = @item_window1
  2917.     when 1
  2918.       @item_window = @item_window2
  2919.     when 2
  2920.       @item_window = @item_window3
  2921.     when 3
  2922.       @item_window = @item_window4
  2923.     when 4
  2924.       @item_window = @item_window5
  2925.     end
  2926.     # If right window is active
  2927.     if @right_window.active
  2928.       # Erase parameters for after equipment change
  2929.       @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil, nil)
  2930.     end
  2931.     # If item window is active
  2932.     if @item_window.active
  2933.       # Get currently selected item
  2934.       item2 = @item_window.item
  2935.       # Change equipment
  2936.       last_hp = @actor.hp
  2937.       last_sp = @actor.sp
  2938.       @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
  2939.       # Get parameters for after equipment change
  2940.       new_atk = @actor.atk
  2941.       new_pdef = @actor.pdef
  2942.       new_mdef = @actor.mdef
  2943.       new_str = @actor.str
  2944.       new_dex = @actor.dex
  2945.       new_agi = @actor.agi
  2946.       new_int = @actor.int
  2947.       new_maxhp = @actor.maxhp
  2948.       new_maxsp = @actor.maxsp
  2949.       # Return equipment
  2950.       @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
  2951.       @actor.hp = last_hp
  2952.       @actor.sp = last_sp
  2953.       # Draw in left window
  2954.       @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_maxhp, new_maxsp, new_str, new_dex, new_agi, new_int)
  2955.     end
  2956.   end
  2957.   #--------------------------------------------------------------------------
  2958.   # * Frame Update
  2959.   #--------------------------------------------------------------------------
  2960.   def update
  2961.    
  2962.     @status_window.update
  2963.     # Update windows
  2964.     @left_window.update
  2965.     @right_window.update
  2966.     @item_window.update
  2967.     refresh
  2968.     @left_window.visible = false
  2969.     # If right window is active: call update_right
  2970.     if @right_window.active
  2971.       update_right
  2972.       return
  2973.     end
  2974.     # If item window is active: call update_item
  2975.     if @item_window.active
  2976.       update_item
  2977.       @left_window.visible = true
  2978.       return
  2979.     end
  2980.   end
  2981.   #--------------------------------------------------------------------------
  2982.   # * Frame Update (when right window is active)
  2983.   #--------------------------------------------------------------------------
  2984.   def update_right
  2985.     # If B button was pressed
  2986.     if Input.trigger?(Input::B)
  2987.       # Play cancel SE
  2988.       $game_system.se_play($data_system.cancel_se)
  2989.       # Switch to menu screen
  2990.       $scene = Scene_Menu.new(2)
  2991.       return
  2992.     end
  2993.     # If C button was pressed
  2994.     if Input.trigger?(Input::C)
  2995.       # If equipment is fixed
  2996.       if @actor.equip_fix?(@right_window.index)
  2997.         # Play buzzer SE
  2998.         $game_system.se_play($data_system.buzzer_se)
  2999.         return
  3000.       end
  3001.       # Play decision SE
  3002.       $game_system.se_play($data_system.decision_se)
  3003.       # Activate item window
  3004.       @right_window.active = false
  3005.       @item_window.active = true
  3006.       @item_window.index = 0
  3007.       return
  3008.     end
  3009.     # If R button was pressed
  3010.     if Input.trigger?(Input::R)
  3011.       # Play cursor SE
  3012.       $game_system.se_play($data_system.cursor_se)
  3013.       # To next actor
  3014.       @actor_index += 1
  3015.       @actor_index %= $game_party.actors.size
  3016.       # Switch to different equipment screen
  3017.       $scene = Scene_Equip.new(@actor_index, @right_window.index)
  3018.       return
  3019.     end
  3020.     # If L button was pressed
  3021.     if Input.trigger?(Input::L)
  3022.       # Play cursor SE
  3023.       $game_system.se_play($data_system.cursor_se)
  3024.       # To previous actor
  3025.       @actor_index += $game_party.actors.size - 1
  3026.       @actor_index %= $game_party.actors.size
  3027.       # Switch to different equipment screen
  3028.       $scene = Scene_Equip.new(@actor_index, @right_window.index)
  3029.       return
  3030.     end
  3031.   end
  3032.   #--------------------------------------------------------------------------
  3033.   # * Frame Update (when item window is active)
  3034.   #--------------------------------------------------------------------------
  3035.   def update_item
  3036.     # If B button was pressed
  3037.     if Input.trigger?(Input::B)
  3038.       # Play cancel SE
  3039.       $game_system.se_play($data_system.cancel_se)
  3040.       # Activate right window
  3041.       @right_window.active = true
  3042.       @item_window.active = false
  3043.       @item_window.index = -1
  3044.       return
  3045.     end
  3046.     # If C button was pressed
  3047.     if Input.trigger?(Input::C)
  3048.       # Play equip SE
  3049.       $game_system.se_play($data_system.equip_se)
  3050.       # Get currently selected data on the item window
  3051.       item = @item_window.item
  3052.       # Change equipment
  3053.       @actor.equip(@right_window.index, item == nil ? 0 : item.id)
  3054.       # Activate right window
  3055.       @right_window.active = true
  3056.       @item_window.active = false
  3057.       @item_window.index = -1
  3058.       # Remake right window and item window contents
  3059.       @right_window.refresh
  3060.       @item_window.refresh
  3061.       return
  3062.     end
  3063.   end
  3064. end
  3065.  
  3066. #==============================================================================
  3067. # ** Scene_Load
  3068. #------------------------------------------------------------------------------
  3069. #  This class performs load screen processing.
  3070. #==============================================================================
  3071. class Scene_Load < Scene_File
  3072.   #--------------------------------------------------------------------------
  3073.   # * Read Save Data
  3074.   #     file : file object for reading (opened)
  3075.   #--------------------------------------------------------------------------
  3076.   def read_save_data(file)
  3077.     # Read character data for drawing save file
  3078.     characters = Marshal.load(file)
  3079.     # Read frame count for measuring play time
  3080.     Graphics.frame_count = Marshal.load(file)
  3081.     # Read each type of game object
  3082.     $game_system        = Marshal.load(file)
  3083.     $game_switches      = Marshal.load(file)
  3084.     $game_variables     = Marshal.load(file)
  3085.     $game_self_switches = Marshal.load(file)
  3086.     $game_screen        = Marshal.load(file)
  3087.     $game_actors        = Marshal.load(file)
  3088.     $game_party         = Marshal.load(file)
  3089.     $game_troop         = Marshal.load(file)
  3090.     $game_map           = Marshal.load(file)
  3091.     $game_player        = Marshal.load(file)
  3092.     $recent_items       = Marshal.load(file)
  3093.     # If magic number is different from when saving
  3094.     # (if editing was added with editor)
  3095.     if $game_system.magic_number != $data_system.magic_number
  3096.       # Load map
  3097.       $game_map.setup($game_map.map_id)
  3098.       $game_player.center($game_player.x, $game_player.y)
  3099.     end
  3100.     # Refresh party members
  3101.     $game_party.refresh
  3102.   end
  3103. end
  3104.  
  3105. #==============================================================================
  3106. # ** Scene_MenuLoad
  3107. #------------------------------------------------------------------------------
  3108. #  This class performs load screen processing.
  3109. #==============================================================================
  3110.  
  3111. class Scene_MenuLoad < Scene_File
  3112.   #--------------------------------------------------------------------------
  3113.   # * Object Initialization
  3114.   #--------------------------------------------------------------------------
  3115.   def initialize
  3116.     # Remake temporary object
  3117.     $game_temp = Game_Temp.new
  3118.     # Timestamp selects new file
  3119.     $game_temp.last_file_index = 0
  3120.     latest_time = Time.at(0)
  3121.     for i in 0..3
  3122.       filename = make_filename(i)
  3123.       if FileTest.exist?(filename)
  3124.         file = File.open(filename, "r")
  3125.         if file.mtime > latest_time
  3126.           latest_time = file.mtime
  3127.           $game_temp.last_file_index = i
  3128.         end
  3129.         file.close
  3130.       end
  3131.     end
  3132.     super("Which file would you like to load?")
  3133.   end
  3134.   #--------------------------------------------------------------------------
  3135.   # * Decision Processing
  3136.   #--------------------------------------------------------------------------
  3137.   def on_decision(filename)
  3138.     # If file doesn't exist
  3139.     unless FileTest.exist?(filename)
  3140.       # Play buzzer SE
  3141.       $game_system.se_play($data_system.buzzer_se)
  3142.       return
  3143.     end
  3144.     # Make system object
  3145.     $game_system = Game_System.new
  3146.     # Play load SE
  3147.     $game_system.se_play($data_system.load_se)
  3148.     # Read save data
  3149.     file = File.open(filename, "rb")
  3150.     read_save_data(file)
  3151.     file.close
  3152.     # Restore BGM and BGS
  3153.     $game_system.bgm_play($game_system.playing_bgm)
  3154.     $game_system.bgs_play($game_system.playing_bgs)
  3155.     # Update map (run parallel process event)
  3156.     $game_map.update
  3157.     # Switch to map screen
  3158.     $scene = Scene_Map.new
  3159.   end
  3160.   #--------------------------------------------------------------------------
  3161.   # * Cancel Processing
  3162.   #--------------------------------------------------------------------------
  3163.   def on_cancel
  3164.     # Play cancel SE
  3165.     $game_system.se_play($data_system.cancel_se)
  3166.     # Switch to title screen
  3167.     $scene = Scene_Menu.new(6)
  3168.   end
  3169.   #--------------------------------------------------------------------------
  3170.   # * Read Save Data
  3171.   #     file : file object for reading (opened)
  3172.   #--------------------------------------------------------------------------
  3173.   def read_save_data(file)
  3174.     # Read character data for drawing save file
  3175.     characters = Marshal.load(file)
  3176.     # Read frame count for measuring play time
  3177.     Graphics.frame_count = Marshal.load(file)
  3178.     # Read each type of game object
  3179.     $game_system        = Marshal.load(file)
  3180.     $game_switches      = Marshal.load(file)
  3181.     $game_variables     = Marshal.load(file)
  3182.     $game_self_switches = Marshal.load(file)
  3183.     $game_screen        = Marshal.load(file)
  3184.     $game_actors        = Marshal.load(file)
  3185.     $game_party         = Marshal.load(file)
  3186.     $game_troop         = Marshal.load(file)
  3187.     $game_map           = Marshal.load(file)
  3188.     $game_player        = Marshal.load(file)
  3189.     $recent_items       = Marshal.load(file)
  3190.     # If magic number is different from when saving
  3191.     # (if editing was added with editor)
  3192.     if $game_system.magic_number != $data_system.magic_number
  3193.       # Load map
  3194.       $game_map.setup($game_map.map_id)
  3195.       $game_player.center($game_player.x, $game_player.y)
  3196.     end
  3197.     # Refresh party members
  3198.     $game_party.refresh
  3199.   end
  3200. end
  3201.  
  3202. #==============================================================================
  3203. # ** Scene_Save
  3204. #------------------------------------------------------------------------------
  3205. #  This class performs save screen processing.
  3206. #==============================================================================
  3207.  
  3208. class Scene_Save < Scene_File
  3209.   #--------------------------------------------------------------------------
  3210.   # * Decision Processing
  3211.   #--------------------------------------------------------------------------
  3212.   def on_decision(filename)
  3213.     # Play save SE
  3214.     $game_system.se_play($data_system.save_se)
  3215.     # Write save data
  3216.     file = File.open(filename, "wb")
  3217.     write_save_data(file)
  3218.     file.close
  3219.     # If called from event
  3220.     if $game_temp.save_calling
  3221.       # Clear save call flag
  3222.       $game_temp.save_calling = false
  3223.       # Switch to map screen
  3224.       $scene = Scene_Map.new
  3225.       return
  3226.     end
  3227.     # Switch to menu screen
  3228.     $scene = Scene_Menu.new(6)
  3229.   end
  3230.   #--------------------------------------------------------------------------
  3231.   # * Cancel Processing
  3232.   #--------------------------------------------------------------------------
  3233.   def on_cancel
  3234.     # Play cancel SE
  3235.     $game_system.se_play($data_system.cancel_se)
  3236.     # If called from event
  3237.     if $game_temp.save_calling
  3238.       # Clear save call flag
  3239.       $game_temp.save_calling = false
  3240.       # Switch to map screen
  3241.       $scene = Scene_Map.new
  3242.       return
  3243.     end
  3244.     # Switch to menu screen
  3245.     $scene = Scene_Menu.new(6)
  3246.   end
  3247.   #--------------------------------------------------------------------------
  3248.   # * Write Save Data
  3249.   #     file : write file object (opened)
  3250.   #--------------------------------------------------------------------------
  3251.   def write_save_data(file)
  3252.     # Make character data for drawing save file
  3253.     characters = []
  3254.     for i in 0...$game_party.actors.size
  3255.       actor = $game_party.actors[i]
  3256.       characters.push([actor.character_name, actor.character_hue])
  3257.     end
  3258.     # Write character data for drawing save file
  3259.     Marshal.dump(characters, file)
  3260.     # Wrire frame count for measuring play time
  3261.     Marshal.dump(Graphics.frame_count, file)
  3262.     # Increase save count by 1
  3263.     $game_system.save_count += 1
  3264.     # Save magic number
  3265.     # (A random value will be written each time saving with editor)
  3266.     $game_system.magic_number = $data_system.magic_number
  3267.     # Write each type of game object
  3268.     Marshal.dump($game_system, file)
  3269.     Marshal.dump($game_switches, file)
  3270.     Marshal.dump($game_variables, file)
  3271.     Marshal.dump($game_self_switches, file)
  3272.     Marshal.dump($game_screen, file)
  3273.     Marshal.dump($game_actors, file)
  3274.     Marshal.dump($game_party, file)
  3275.     Marshal.dump($game_troop, file)
  3276.     Marshal.dump($game_map, file)
  3277.     Marshal.dump($game_player, file)
  3278.     Marshal.dump($recent_items, file)
  3279.   end
  3280. end
  3281.  
  3282. #==============================================================================
  3283. # ** Scene_Title
  3284. #------------------------------------------------------------------------------
  3285. #  This class performs title screen processing.
  3286. #==============================================================================
  3287. class Scene_Title
  3288.   #--------------------------------------------------------------------------
  3289.   # * Main Processing
  3290.   #--------------------------------------------------------------------------
  3291.   def main
  3292.     # If battle test
  3293.     if $BTEST
  3294.       battle_test
  3295.       return
  3296.     end
  3297.     # Load database
  3298.     $data_actors        = load_data("Data/Actors.rxdata")
  3299.     $data_classes       = load_data("Data/Classes.rxdata")
  3300.     $data_skills        = load_data("Data/Skills.rxdata")
  3301.     $data_items         = load_data("Data/Items.rxdata")
  3302.     $data_weapons       = load_data("Data/Weapons.rxdata")
  3303.     $data_armors        = load_data("Data/Armors.rxdata")
  3304.     $data_enemies       = load_data("Data/Enemies.rxdata")
  3305.     $data_troops        = load_data("Data/Troops.rxdata")
  3306.     $data_states        = load_data("Data/States.rxdata")
  3307.     $data_animations    = load_data("Data/Animations.rxdata")
  3308.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  3309.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  3310.     $data_system        = load_data("Data/System.rxdata")
  3311.     # Make system object
  3312.     $game_system = Game_System.new
  3313.     # Make the actor face variable
  3314.     $change_face = Change_Face.new
  3315.     # Make title graphic
  3316.     @sprite = Sprite.new
  3317.     @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  3318.     # Make command window
  3319.     s1 = "New Game"
  3320.     s2 = "Continue"
  3321.     s3 = "Shutdown"
  3322.     @command_window = Window_Command.new(192, [s1, s2, s3])
  3323.     @command_window.back_opacity = 160
  3324.     @command_window.x = 320 - @command_window.width / 2
  3325.     @command_window.y = 288
  3326.     # Continue enabled determinant
  3327.     # Check if at least one save file exists
  3328.     # If enabled, make @continue_enabled true; if disabled, make it false
  3329.     @continue_enabled = false
  3330.     for i in 0..3
  3331.       if FileTest.exist?("Save#{i+1}.rxdata")
  3332.         @continue_enabled = true
  3333.       end
  3334.     end
  3335.     # If continue is enabled, move cursor to "Continue"
  3336.     # If disabled, display "Continue" text in gray
  3337.     if @continue_enabled
  3338.       @command_window.index = 1
  3339.     else
  3340.       @command_window.disable_item(1)
  3341.     end
  3342.     # Play title BGM
  3343.     $game_system.bgm_play($data_system.title_bgm)
  3344.     # Stop playing ME and BGS
  3345.     Audio.me_stop
  3346.     Audio.bgs_stop
  3347.     # Execute transition
  3348.     Graphics.transition
  3349.     # Main loop
  3350.     loop do
  3351.       # Update game screen
  3352.       Graphics.update
  3353.       # Update input information
  3354.       Input.update
  3355.       # Frame update
  3356.       update
  3357.       # Abort loop if screen is changed
  3358.       if $scene != self
  3359.         break
  3360.       end
  3361.     end
  3362.     # Prepare for transition
  3363.     Graphics.freeze
  3364.     # Dispose of command window
  3365.     @command_window.dispose
  3366.     # Dispose of title graphic
  3367.     @sprite.bitmap.dispose
  3368.     @sprite.dispose
  3369.   end
  3370.   alias cms_cmdng_title command_new_game
  3371.   def command_new_game
  3372.     $recent_items = []
  3373.     cms_cmdng_title
  3374.   end
  3375.   #--------------------------------------------------------------------------
  3376.   # * Create the global variable that will hold the current map name
  3377.   #--------------------------------------------------------------------------
  3378.   $map_location = load_data("Data/MapInfos.rxdata")
  3379.   for key in $map_location.keys
  3380.     $map_location[key] = $map_location[key].name
  3381.   end
  3382. end
  3383.  
  3384. #==============================================================================
  3385. # ** Game_Map
  3386. #------------------------------------------------------------------------------
  3387. #  This class handles the map. It includes scrolling and passable determining
  3388. #  functions. Refer to "$game_map" for the instance of this class.
  3389. #==============================================================================
  3390. class Game_Map
  3391.   #--------------------------------------------------------------------------
  3392.   # * Getting the Name of the Map
  3393.   #--------------------------------------------------------------------------
  3394.   def name
  3395.     $map_location[@map_id]
  3396.   end
  3397. end
  3398.  
  3399. #==============================================================================
  3400. # ** Change_Face
  3401. #------------------------------------------------------------------------------
  3402. #  This class allows you to change an actors face throughout the game using
  3403. #  a simple script.
  3404. #==============================================================================
  3405. class Change_Face
  3406.   #--------------------------------------------------------------------------
  3407.   # * Object Initialization
  3408.   #--------------------------------------------------------------------------
  3409.   def initialize
  3410.     @actor = []
  3411.     @actor_face = []
  3412.     # Load the actors data for every actor into @actors
  3413.     for i in 1...$data_actors.size
  3414.       @actor[i] = $data_actors[i]
  3415.     end
  3416.     # Set the actors face graphic file name to the name of the actor
  3417.     for i in 1...$data_actors.size
  3418.       @actor_face[i] = @actor[i].name
  3419.     end
  3420.   end
  3421.  
  3422.   #--------------------------------------------------------------------------
  3423.   # * New face graphic
  3424.   #     name : the name of the actor
  3425.   #     face : the name of the new face file
  3426.   #--------------------------------------------------------------------------
  3427.   def new(name, face)
  3428.     for i in 1...@actor.size
  3429.       if @actor[i].name == name
  3430.         @actor_face[i] = face
  3431.       end
  3432.     end
  3433.   end
  3434.  
  3435.   #--------------------------------------------------------------------------
  3436.   # * Face of the Actor
  3437.   #     id : the id of the actor
  3438.   #--------------------------------------------------------------------------
  3439.   def face(id)
  3440.     return @actor_face[id]
  3441.   end
  3442. end
  3443.  
  3444. #==============================================================================
  3445. # ** Game_Party
  3446. #------------------------------------------------------------------------------
  3447. #  This class handles the party. It includes information on amount of gold
  3448. #  and items. Refer to "$game_party" for the instance of this class.
  3449. #==============================================================================
  3450. class Game_Party
  3451.   #--------------------------------------------------------------------------
  3452.   # * Gain Items (or lose)
  3453.   #     item_id : item ID
  3454.   #     n       : quantity
  3455.   #--------------------------------------------------------------------------
  3456.   def gain_item(item_id, n)
  3457.     # Update quantity data in the hash.
  3458.     if item_id > 0
  3459.       @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
  3460.       gain_recent_item(item_id) if n >= 0
  3461.     end
  3462.   end
  3463.   #--------------------------------------------------------------------------
  3464.   # * Gain Weapons (or lose)
  3465.   #     weapon_id : weapon ID
  3466.   #     n         : quantity
  3467.   #--------------------------------------------------------------------------
  3468.   def gain_weapon(weapon_id, n)
  3469.     # Update quantity data in the hash.
  3470.     if weapon_id > 0
  3471.       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
  3472.       gain_recent_weapon(weapon_id) if n >= 0
  3473.     end
  3474.   end
  3475.   #--------------------------------------------------------------------------
  3476.   # * Gain Armor (or lose)
  3477.   #     armor_id : armor ID
  3478.   #     n        : quantity
  3479.   #--------------------------------------------------------------------------
  3480.   def gain_armor(armor_id, n)
  3481.     # Update quantity data in the hash.
  3482.     if armor_id > 0
  3483.       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
  3484.       gain_recent_armor(armor_id) if n >= 0
  3485.     end
  3486.   end
  3487.   #--------------------------------------------------------------------------
  3488.   # * Lose Items
  3489.   #     item_id : item ID
  3490.   #     n       : quantity
  3491.   #--------------------------------------------------------------------------
  3492.   def lose_item(item_id, n)
  3493.     # Reverse the numerical value and call it gain_item
  3494.     gain_item(item_id, -n)
  3495.     for i in 0...$recent_items.size
  3496.       if $game_party.item_number($recent_items[i].id) == 0 && $recent_items[i].is_a?(RPG::Item) && $recent_items[i].id == item_id
  3497.         $recent_items.delete_at(i)
  3498.       end
  3499.     end
  3500.   end
  3501.   #--------------------------------------------------------------------------
  3502.   # * Lose Weapons
  3503.   #     weapon_id : weapon ID
  3504.   #     n         : quantity
  3505.   #--------------------------------------------------------------------------
  3506.   def lose_weapon(weapon_id, n)
  3507.     # Reverse the numerical value and call it gain_weapon
  3508.     gain_weapon(weapon_id, -n)
  3509.     for i in 0...$recent_items.size
  3510.       if $game_party.item_number($recent_items[i].id) == 0 && $recent_items[i].is_a?(RPG::Weapon) && $recent_items[i].id == weapon_id
  3511.         $recent_items.delete_at(i)
  3512.       end
  3513.     end
  3514.   end
  3515.   #--------------------------------------------------------------------------
  3516.   # * Lose Armor
  3517.   #     armor_id : armor ID
  3518.   #     n        : quantity
  3519.   #--------------------------------------------------------------------------
  3520.   def lose_armor(armor_id, n)
  3521.     # Reverse the numerical value and call it gain_armor
  3522.     gain_armor(armor_id, -n)
  3523.     if $game_party.item_number(armor_id) <= 0
  3524.     for i in 0...$recent_items.size
  3525.       if $game_party.item_number($recent_items[i].id) == 0 && $recent_items[i].is_a?(RPG::Armor) && $recent_items[i].id == armor_id
  3526.         $recent_items.delete_at(i)
  3527.       end
  3528.     end
  3529.     end
  3530.   end
  3531.   #--------------------------------------------------------------------------
  3532.   # * Gain Recent Items
  3533.   #     item_id  : item ID
  3534.   #--------------------------------------------------------------------------
  3535.   def gain_recent_item(item_id)
  3536.     for i in 0...$recent_items.size
  3537.       if $recent_items[i].id == $data_items[item_id].id && $recent_items[i].is_a?(RPG::Item)
  3538.         $recent_items.delete_at(i)
  3539.       end
  3540.     end
  3541.     $recent_items.push($data_items[item_id])
  3542.     if $recent_items.size > 40
  3543.       $recent_items.delete_at(0)
  3544.     end
  3545.   end
  3546.   #--------------------------------------------------------------------------
  3547.   # * Gain Recent Weapons
  3548.   #     weapon_id : weapon ID
  3549.   #--------------------------------------------------------------------------
  3550.   def gain_recent_weapon(weapon_id)
  3551.     for i in 0...$recent_items.size
  3552.       if $recent_items[i].id == $data_weapons[weapon_id].id && $recent_items[i].is_a?(RPG::Weapon)
  3553.         $recent_items.delete_at(i)
  3554.       end
  3555.     end
  3556.     $recent_items.push($data_weapons[weapon_id])
  3557.     if $recent_items.size > 40
  3558.       $recent_items.delete_at(0)
  3559.     end
  3560.   end
  3561.   #--------------------------------------------------------------------------
  3562.   # * Gain Recent Armor
  3563.   #     armor_id  : armor ID
  3564.   #--------------------------------------------------------------------------
  3565.   def gain_recent_armor(armor_id)
  3566.     for i in 0...$recent_items.size
  3567.       if $recent_items[i].id == $data_armors[armor_id].id && $recent_items[i].is_a?(RPG::Armor)
  3568.         $recent_items.delete_at(i)
  3569.       end
  3570.     end
  3571.     $recent_items.push($data_armors[armor_id])
  3572.     if $recent_items.size > 40
  3573.       $recent_items.delete_at(0)
  3574.     end
  3575.   end
  3576.   #--------------------------------------------------------------------------
  3577.   # * Gain Items (or lose)
  3578.   #     item_id : item ID
  3579.   #     n       : quantity
  3580.   #--------------------------------------------------------------------------
  3581.   def equip_item(item_id, n)
  3582.     # Update quantity data in the hash.
  3583.     if item_id > 0
  3584.       @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
  3585.     end
  3586.   end
  3587.   #--------------------------------------------------------------------------
  3588.   # * Gain Weapons (or lose)
  3589.   #     weapon_id : weapon ID
  3590.   #     n         : quantity
  3591.   #--------------------------------------------------------------------------
  3592.   def equip_weapon(weapon_id, n)
  3593.     # Update quantity data in the hash.
  3594.     if weapon_id > 0
  3595.       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
  3596.     end
  3597.   end
  3598.   #--------------------------------------------------------------------------
  3599.   # * Gain Armor (or lose)
  3600.   #     armor_id : armor ID
  3601.   #     n        : quantity
  3602.   #--------------------------------------------------------------------------
  3603.   def equip_armor(armor_id, n)
  3604.     # Update quantity data in the hash.
  3605.     if armor_id > 0
  3606.       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
  3607.     end
  3608.   end
  3609. end
  3610.  
  3611. class Game_Actor
  3612.   #--------------------------------------------------------------------------
  3613.   # * Change Equipment
  3614.   #     equip_type : type of equipment
  3615.   #     id    : weapon or armor ID (If 0, remove equipment)
  3616.   #--------------------------------------------------------------------------
  3617.   def equip(equip_type, id)
  3618.     case equip_type
  3619.     when 0  # Weapon
  3620.       if id == 0 or $game_party.weapon_number(id) > 0
  3621.         $game_party.equip_weapon(@weapon_id, 1)
  3622.         @weapon_id = id
  3623.         $game_party.lose_weapon(id, 1)
  3624.       end
  3625.     when 1  # Shield
  3626.       if id == 0 or $game_party.armor_number(id) > 0
  3627.         update_auto_state($data_armors[@armor1_id], $data_armors[id])
  3628.         $game_party.equip_armor(@armor1_id, 1)
  3629.         @armor1_id = id
  3630.         $game_party.lose_armor(id, 1)
  3631.       end
  3632.     when 2  # Head
  3633.       if id == 0 or $game_party.armor_number(id) > 0
  3634.         update_auto_state($data_armors[@armor2_id], $data_armors[id])
  3635.         $game_party.equip_armor(@armor2_id, 1)
  3636.         @armor2_id = id
  3637.         $game_party.lose_armor(id, 1)
  3638.       end
  3639.     when 3  # Body
  3640.       if id == 0 or $game_party.armor_number(id) > 0
  3641.         update_auto_state($data_armors[@armor3_id], $data_armors[id])
  3642.         $game_party.equip_armor(@armor3_id, 1)
  3643.         @armor3_id = id
  3644.         $game_party.lose_armor(id, 1)
  3645.       end
  3646.     when 4  # Accessory
  3647.       if id == 0 or $game_party.armor_number(id) > 0
  3648.         update_auto_state($data_armors[@armor4_id], $data_armors[id])
  3649.         $game_party.equip_armor(@armor4_id, 1)
  3650.         @armor4_id = id
  3651.         $game_party.lose_armor(id, 1)
  3652.       end
  3653.     end
  3654.   end
  3655. end
  3656.  
  3657. #==============================================================================
  3658. # ** Arrow_Actor
  3659. #------------------------------------------------------------------------------
  3660. #  This arrow cursor is used to choose an actor. This class inherits from the
  3661. #  Arrow_Base class.
  3662. #==============================================================================
  3663.  
  3664. class Arrow_Actor < Arrow_Base
  3665.   #--------------------------------------------------------------------------
  3666.   # * Get Actor Indicated by Cursor
  3667.   #--------------------------------------------------------------------------
  3668.   def actor
  3669.     return $game_party.actors[@index]
  3670.   end
  3671.   #--------------------------------------------------------------------------
  3672.   # * Frame Update
  3673.   #--------------------------------------------------------------------------
  3674.   def update
  3675.     super
  3676.     # Cursor right
  3677.     if Input.repeat?(Input::RIGHT)
  3678.       $game_system.se_play($data_system.cursor_se)
  3679.       @index += 1
  3680.       if $game_party.actors.size <= 4
  3681.         @index %= $game_party.actors.size
  3682.       else
  3683.         @index %= 4
  3684.       end
  3685.     end
  3686.     # Cursor left
  3687.     if Input.repeat?(Input::LEFT)
  3688.       $game_system.se_play($data_system.cursor_se)
  3689.       if $game_party.actors.size <= 4
  3690.         @index += $game_party.actors.size - 1
  3691.         @index %= $game_party.actors.size
  3692.       else
  3693.         @index += 3
  3694.         @index %= 4
  3695.       end
  3696.     end
  3697.     # Set sprite coordinates
  3698.     if self.actor != nil
  3699.       self.x = self.actor.screen_x
  3700.       self.y = self.actor.screen_y
  3701.     end
  3702.   end
  3703.   #--------------------------------------------------------------------------
  3704.   # * Help Text Update
  3705.   #--------------------------------------------------------------------------
  3706.   def update_help
  3707.     # Display actor status in help window
  3708.     @help_window.set_actor(self.actor)
  3709.   end
  3710. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement