Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #============================================================================
  2. # Miraki - Main Menu
  3. #============================================================================
  4. # Infomation
  5. #-----------------------------------
  6. #Author: Miraki
  7. #Version: Beta 1.0
  8. # Script use for RPG Maker XP (RGSS1)
  9. #-----------------------------------
  10. #Tutorial:
  11. #Add into your script editor.
  12. #-----------------------------------
  13. # Nothing about this !
  14. #=============================================================================
  15. class Game_Actor < Game_Battler
  16.     #----------------------------------------------------
  17.     #Exp
  18.     #----------------------------------------------------
  19.     def now_exp
  20.         return @exp - @exp_list[@level]
  21.     end
  22.     def next_exp
  23.         return @exp_list[@level + 1] > 0 ? @exp_list[@level + 1] - @exp_list[@level] : @exp_list[@level] = 1
  24.     end
  25. end
  26. #========================================================
  27. #--------------------------------------------------------
  28. #Window_Gold
  29. #--------------------------------------------------------
  30. class Window_Gold < Window_Base
  31.   def initialize
  32.     super(0, 0, 160, 64)
  33.     self.contents = Bitmap.new(width - 32, height - 32)
  34.     self.opacity = 0
  35.     refresh
  36.   end
  37.   def refresh
  38.     self.contents.clear
  39.     cx = contents.text_size($data_system.words.gold).width
  40.     self.contents.font.color = system_color
  41.     self.contents.draw_text(-20, 0, cx + 100, 32, "Money: ", 2)
  42.     self.contents.font.color = normal_color
  43.     self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
  44.     self.contents.font.color = system_color
  45.     self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
  46.   end
  47. end
  48. #========================================================
  49. #--------------------------------------------------------
  50. #Window_Location
  51. #--------------------------------------------------------
  52. class Game_Map
  53.     attr_reader :map_id
  54.     def map_name
  55.         $map_name = load_data("Data/MapInfos.rxdata")
  56.         $map_name[@map_id].name
  57.     end
  58. end
  59. #========================================================
  60. #--------------------------------------------------------
  61. #Window_MapName
  62. #--------------------------------------------------------
  63. class Window_Mapname < Window_Base
  64.   def initialize
  65.     super(0, 0, 160, 96)
  66.     self.contents = Bitmap.new(width - 32, height - 32)
  67.     self.contents.font.name = "Arial"
  68.     self.contents.font.size = 22
  69.     refresh
  70.   end
  71.  
  72.   def refresh
  73.     self.contents.clear
  74.     self.contents.font.color = system_color
  75.     lx = contents.text_size("Location").width
  76.     self.contents.draw_text(4, -55, lx, 144, "Location", 1)
  77.     self.contents.font.color = normal_color
  78.     self.contents.font.size = 20
  79.     self.contents.draw_text(0, 0, 110, 106, $game_map.mpname.to_s)
  80.     bitmap = RPG::Cache.icon("038-Item07")
  81.     self.contents.blt(105, 40, bitmap, Rect.new(0, 0, 24, 24))
  82.   end
  83. end
  84. #========================================================
  85. #==============================================================================
  86. # ** Window_PlayTime
  87. #------------------------------------------------------------------------------
  88. #  This window displays play time on the menu screen.
  89. #==============================================================================
  90.  
  91. class Window_PlayTime < Window_Base
  92.   #--------------------------------------------------------------------------
  93.   # * Object Initialization
  94.   #--------------------------------------------------------------------------
  95.   def initialize
  96.     super(0, 0, 160, 96)
  97.     self.contents = Bitmap.new(width - 32, height - 32)
  98.     refresh
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Refresh
  102.   #--------------------------------------------------------------------------
  103.   def refresh
  104.     self.contents.clear
  105.     self.contents.font.color = system_color
  106.     self.contents.draw_text(4, 0, 120, 32, "Time: ")
  107.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  108.     hour = @total_sec / 60 / 60
  109.     min = @total_sec / 60 % 60
  110.     sec = @total_sec % 60
  111.     text = sprintf("%02d:%02d:%02d", hour, min, sec)
  112.     self.contents.font.color = normal_color
  113.     self.contents.draw_text(4, 32, 120, 32, text, 2)
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # * Frame Update
  117.   #--------------------------------------------------------------------------
  118.   def update
  119.     super
  120.     if Graphics.frame_count / Graphics.frame_rate != @total_sec
  121.       refresh
  122.     end
  123.   end
  124. end
  125. #========================================================
  126.  
  127. class Window_Steps < Window_Base
  128.   #--------------------------------------------------------------------------
  129.   # * Object Initialization
  130.   #--------------------------------------------------------------------------
  131.   def initialize
  132.     super(0, 0, 160, 96)
  133.     self.contents = Bitmap.new(width - 32, height - 32)
  134.     refresh
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # * Refresh
  138.   #--------------------------------------------------------------------------
  139.   def refresh
  140.     self.contents.clear
  141.     self.contents.font.color = system_color
  142.     self.contents.draw_text(4, 0, 120, 32, "Step Count")
  143.     self.contents.font.color = normal_color
  144.     self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2)
  145.   end
  146. end
  147. #========================================================
  148. #--------------------------------------------------------
  149. #Window_Base
  150. #--------------------------------------------------------
  151. class Window_Base < Window
  152.     #----------------------------------------------------
  153.     #Draw_Actor_Pic
  154.     #----------------------------------------------------
  155.     def draw_actors_pic(actor, x, y)
  156.         bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  157.         draw_ac_pic_cw = bitmap.width / 4
  158.         draw_ac_pic_ch = bitmap.height / 4
  159.         actorpic_rect = Rect.new(0, 0, draw_ac_pic_cw, draw_ac_pic_ch)
  160.         self.contents.blt(x - draw_ac_pic_cw / 2, y - draw_ac_pic_ch, bitmap, actorpic_rect)
  161.     end
  162.     #----------------------------------------------------
  163.     #Draw_Actor_Name
  164.     #----------------------------------------------------
  165.     def draw_actors_name(actor, x, y)
  166.         self.contents.font.color = normal_color
  167.         self.contents.font.size = 20
  168.         self.contents.font.name = "Arial"
  169.         self.contents.draw_text(x, y, 200, 32, actor.name)
  170.     end
  171.     #----------------------------------------------------
  172.     #Draw_Actor_Class
  173.     #----------------------------------------------------
  174.     def draw_actors_class(actor, x, y)
  175.         self.contents.font.color = normal_color
  176.         self.contents.font.size = 16
  177.         self.contents.font.name = "Arial"
  178.         self.contents.draw_text(x, y, 236, 32, "Class: " + actor.class_name)
  179.     end
  180.     #----------------------------------------------------
  181.     #Draw_Level_Number
  182.     #----------------------------------------------------
  183.     def draw_actors_level(actor, x, y)
  184.         self.contents.font.color = system_color
  185.         self.contents.font.size = 16
  186.         self.contents.draw_text(x, y, 32, 32, "Level")
  187.         self.contents.font.color = normal_color
  188.         self.contents.font.size = 16
  189.         self.contents.draw_text(x + 24, y, 24, 32, actor.level.to_s, 2)
  190.     end
  191.     #----------------------------------------------------
  192.     #Draw_Actor_bar_hp
  193.     #----------------------------------------------------
  194.     def draw_actors_hp(actor, x, y, x_pa, y_pa, fontsize, width = 144)
  195.         # Draw "HP" text string
  196.         self.contents.font.color = system_color
  197.         self.contents.font.size = 20
  198.         self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
  199.         # Calculate if there is draw space for MaxHP
  200.         if width - 32 >= 108
  201.             hp_x = x_pa + width - 108
  202.             flag = true
  203.         elsif width - 32 >= 48
  204.             hp_x = x_pa + width - 48
  205.             flag = false
  206.         end
  207.         # Draw HP
  208.         self.contents.font.size = fontsize
  209.         self.contents.font.color = actor.hp == 0 ? knockout_color :
  210.         actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  211.         self.contents.draw_text(hp_x, y_pa, 48, 32, actor.hp.to_s, 2)
  212.         # Draw MaxHP
  213.         if flag
  214.             self.contents.font.color = normal_color
  215.             self.contents.font.size = fontsize
  216.             self.contents.draw_text(hp_x + 48, y_pa, 12, 32, "/", 1)
  217.             self.contents.draw_text(hp_x + 60, y_pa, 48, 32, actor.maxhp.to_s)
  218.         end
  219.     end
  220.     #----------------------------------------------------
  221.     #Draw_Actor_bar_sp
  222.     #----------------------------------------------------
  223.     def draw_actors_sp(actor, x, y, x_pa, y_pa, fontsize, width = 144)
  224.         # Draw "SP" text string
  225.         self.contents.font.color = system_color
  226.         self.contents.font.size = 20
  227.         self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
  228.         # Calculate if there is draw space for MaxHP
  229.         if width - 32 >= 108
  230.             sp_x = x_pa + width - 108
  231.             flag = true
  232.         elsif width - 32 >= 48
  233.             sp_x = x_pa + width - 48
  234.             flag = false
  235.         end
  236.         # Draw SP
  237.         self.contents.font.size = fontsize
  238.         self.contents.font.color = actor.sp == 0 ? knockout_color :
  239.         actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  240.         self.contents.draw_text(sp_x, y_pa, 48, 32, actor.sp.to_s, 2)
  241.         # Draw MaxSP
  242.         if flag
  243.             self.contents.font.color = normal_color
  244.             self.contents.font.size = fontsize
  245.             self.contents.draw_text(sp_x + 48, y_pa, 12, 32, "/", 1)
  246.             self.contents.draw_text(sp_x + 60, y_pa, 48, 32, actor.maxsp.to_s)
  247.         end
  248.     end
  249.     #----------------------------------------------------
  250.     #Draw_Actor_bar_exp
  251.     #----------------------------------------------------
  252.     def draw_actors_exp(actor, x, y, x_pa, y_pa, fontsize, width = 144)
  253.         # Draw "EXP" text string
  254.         self.contents.font.color = system_color
  255.         self.contents.font.size = 20
  256.         self.contents.draw_text(x, y, 40, 40, "Exp")
  257.         # Calculate if there is draw space for MaxEXP
  258.         if width - 32 >= 108
  259.             exp_x = x_pa + width - 108
  260.             flag = true
  261.         elsif width - 32 >= 48
  262.             exp_x = x_pa + width - 48
  263.             flag = false
  264.         end
  265.         # Draw EXP
  266.         self.contents.font.color = actor.now_exp == 0 ? knockout_color :
  267.         actor.now_exp <= actor.next_exp / 4 ? crisis_color : normal_color
  268.         self.contents.font.size = fontsize
  269.         self.contents.draw_text(exp_x, y_pa, 48, 32, actor.now_exp.to_s, 2)
  270.         # Draw MaxEXP
  271.         if flag
  272.             self.contents.font.color = normal_color
  273.             self.contents.font.size = fontsize
  274.             self.contents.draw_text(exp_x + 48, y_pa, 12, 32, "/", 1)
  275.             self.contents.draw_text(exp_x + 60, y_pa, 48, 32, actor.next_exp.to_s)
  276.         end
  277.     end
  278.     #----------------------------------------------------
  279.     #Draw_Parameter
  280.     #----------------------------------------------------
  281.     def draw_parameter_menu(x, y, fsize, paraname)
  282.         self.contents.font.size = fsize
  283.         self.contents.font.color = system_color
  284.         self.contents.font.name = "Arial"
  285.         self.contents.draw_text(x, y, 200, 100, paraname, 1)
  286.     end
  287.     #----------------------------------------------------
  288.     #Draw_ATK_parameter
  289.     #----------------------------------------------------
  290.     def draw_atk_parameter(actor, x, y)
  291.         self.contents.font.size = 18
  292.         self.contents.font.color = normal_color
  293.         self.contents.font.name = "Arial"
  294.         self.contents.draw_text(x, y, 200, 100, "ATK: ")
  295.         self.contents.draw_text(x + 45, y, 200, 100, actor.atk.to_s)
  296.     end
  297.     #----------------------------------------------------
  298.     #Draw_DEF_parameter
  299.     #----------------------------------------------------
  300.     def draw_def_parameter(actor, x, y)
  301.         self.contents.font.size = 18
  302.         self.contents.font.color = normal_color
  303.         self.contents.font.name = "Arial"
  304.         self.contents.draw_text(x, y + 32, 200, 100, "DEF: ")
  305.         self.contents.draw_text(x + 45, y + 32, 200, 100, actor.pdef.to_s)
  306.     end
  307.     #----------------------------------------------------
  308.     #Draw_MDEF_parameter
  309.     #----------------------------------------------------
  310.     def draw_mdef_parameter(actor, x, y)
  311.         self.contents.font.size = 18
  312.         self.contents.font.color = normal_color
  313.         self.contents.font.name = "Arial"
  314.         self.contents.draw_text(x, y, 200, 100, "Magic DEF: ")
  315.         self.contents.draw_text(x + 90, y, 200, 100, actor.mdef.to_s)
  316.     end
  317.     #----------------------------------------------------
  318.     #Draw_STR_parameter
  319.     #----------------------------------------------------
  320.     def draw_str_parameter(actor, x, y)
  321.         self.contents.font.size = 18
  322.         self.contents.font.color = normal_color
  323.         self.contents.font.name = "Arial"
  324.         self.contents.draw_text(x, y + 64, 200, 100, "STR: ")
  325.         self.contents.draw_text(x + 45, y + 64, 200, 100, actor.str.to_s)
  326.     end
  327.     #----------------------------------------------------
  328.     #Draw_DEX_parameter
  329.     #----------------------------------------------------
  330.     def draw_dex_parameter(actor, x, y)
  331.         self.contents.font.size = 18
  332.         self.contents.font.color = normal_color
  333.         self.contents.font.name = "Arial"
  334.         self.contents.draw_text(x, y + 32, 200, 100, "DEX: ")
  335.         self.contents.draw_text(x + 45, y + 32, 200, 100, actor.dex.to_s)
  336.     end
  337.     #----------------------------------------------------
  338.     #Draw_AGI_parameter
  339.     #----------------------------------------------------
  340.     def draw_agi_parameter(actor, x, y)
  341.         self.contents.font.size = 18
  342.         self.contents.font.color = normal_color
  343.         self.contents.font.name = "Arial"
  344.         self.contents.draw_text(x, y + 64, 200, 100, "AGI: ")
  345.         self.contents.draw_text(x + 45, y + 64, 200, 100, actor.agi.to_s)
  346.     end
  347.     #----------------------------------------------------
  348.     #Draw_INT_parameter
  349.     #----------------------------------------------------
  350.     def draw_int_parameter(actor, x, y)
  351.         self.contents.font.size = 18
  352.         self.contents.font.color = normal_color
  353.         self.contents.font.name = "Arial"
  354.         self.contents.draw_text(x, y + 96, 200, 100, "INT: ")
  355.         self.contents.draw_text(x + 45, y + 96, 200, 100, actor.int.to_s)
  356.     end
  357.     #----------------------------------------------------
  358.     #Draw_Actor_Picture
  359.     #----------------------------------------------------
  360.     def draw_actors_picture(actor, x, y)
  361.         bitmap = RPG::Cache.picture(actor.character_name + "_pic")
  362.         cw = bitmap.width
  363.         ch = bitmap.height
  364.         sr_rect = Rect.new(0, 0, cw, ch)
  365.         self.contents.blt(x, y, bitmap, sr_rect, 40)
  366.     end
  367.     #--------------------------------------------------------------------------
  368.     # * Draw Icon
  369.     #--------------------------------------------------------------------------
  370.     def draw_icon(actor, x, y, type)
  371.     case type
  372.         when 1
  373.             img_name = "028-Herb04"
  374.         when 2
  375.             img_name = "032-Item01"
  376.         when 3
  377.             img_name = "050-Skill07"
  378.         when 4
  379.             img_name = "001-Weapon01"
  380.         when 5
  381.             img_name = "011-Head02"
  382.         when 6
  383.             img_name = "037-Item06"
  384.         when 7
  385.             img_name = "039-Item08"
  386.         when 8
  387.             img_name = "048-Skill05"
  388.         when 9
  389.             img_name = "040-Item09"
  390.         when 10
  391.             img_name = "046-Skill03"
  392.     end
  393.     bitmap = RPG::Cache.icon(img_name)
  394.     cw = bitmap.width
  395.     ch = bitmap.height
  396.     src_rect = Rect.new(0, 0, cw, ch)
  397.     self.contents.blt(x, y, bitmap, src_rect, 100)
  398.     end
  399.     #--------------------------------------------------------------------------
  400.     # * Draw parameters bar
  401.     #--------------------------------------------------------------------------
  402.     def draw_parameter_bar(actor, x, y, width, type)
  403.         case type
  404.             when 1 #Health
  405.             color = Color.new(255, 0, 0)
  406.             color2 = Color.new(200, 0, 0)
  407.             width = actor.hp.to_f / actor.maxhp.to_f * 100 * 2
  408.             when 2 #SP
  409.             color = Color.new(0, 0, 255)
  410.             color2 = Color.new(0, 0, 200)
  411.             width = actor.sp.to_f / actor.maxsp.to_f * 100 * 2
  412.             when 3 #Exp
  413.             color = Color.new(0, 255, 0)
  414.             color2 = Color.new(0, 200, 0)
  415.             width = actor.now_exp.to_f / actor.next_exp.to_f * 100 * 2
  416.         end
  417.         self.contents.fill_rect(x, y, 202, 4, Color.new(0, 0, 0))
  418.         self.contents.fill_rect(x + 1, y + 1, width, 1, color2)
  419.         self.contents.fill_rect(x + 1, y + 2, width, 1, color)
  420.     end
  421.     #--------------------------------------------------------------------------
  422.     # * Draw icon item
  423.     #--------------------------------------------------------------------------
  424.     def draw_item_icon(item, x, y)
  425.         if item == nil
  426.             return
  427.         end
  428.         bitmap = RPG::Cache.icon(item.icon_name)
  429.         self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  430.         self.contents.font.color = normal_color
  431.         self.contents.font.size = 16
  432.     end
  433.  
  434. end
  435. #========================================================
  436. class Window_MenuStatus < Window_Selectable
  437.     def initialize
  438.         super(0, 0, 640, 500)
  439.         self.contents = Bitmap.new(width - 32, height - 32)
  440.         refresh
  441.         self.active = false
  442.         self.index = -1
  443.         self.opacity = 225
  444.         self.x = 64
  445.         self.y = 0
  446.     end
  447.     def refresh
  448.         self.contents.clear
  449.         self.windowskin = RPG::Cache.windowskin("3")
  450.         @item_max = $game_party.actors.size
  451.         for i in 0...$game_party.actors.size
  452.             x = 64
  453.             y = 0
  454.             actor = $game_party.actors[0]
  455.             draw_actors_picture(actor, x + 100, y + 100)
  456.             draw_actors_pic(actor, x - 40, y + 80)
  457.             draw_actors_exp(actor, x + 100, y + 30, 230, 25, 15)
  458.             draw_actors_hp(actor, x, y + 64, 120, 58, 15)
  459.             draw_actors_sp(actor, x, y + 96, 120, 90, 15)
  460.             draw_actors_name(actor, x - 40, y)
  461.             draw_actors_class(actor, x + 104, y)
  462.             draw_actors_level(actor, x, y + 32)
  463.             #Draw Parameters
  464.             draw_parameter_menu(x - 20, y + 100, 26, "Parameters")
  465.             draw_atk_parameter(actor, x, y + 132)
  466.             draw_def_parameter(actor, x, y + 132)
  467.             draw_mdef_parameter(actor, x + 25, y + 230)
  468.             draw_str_parameter(actor, x, y + 132)
  469.             draw_dex_parameter(actor, x + 100, y + 100)
  470.             draw_agi_parameter(actor, x + 100, y + 100)
  471.             draw_int_parameter(actor, x + 100, y + 100)
  472.             #Draw icon menu
  473.             draw_icon(actor, x + 430, y + 53, 1)
  474.             draw_icon(actor, x + 430, y + 85, 2)
  475.             draw_icon(actor, x + 430, y + 117, 3)
  476.             draw_icon(actor, x + 430, y + 149, 4)
  477.             draw_icon(actor, x + 430, y + 181, 5)
  478.             draw_icon(actor, x + 430, y + 213, 6)
  479.             draw_icon(actor, x + 430, y + 245, 7)
  480.             draw_icon(actor, x + 430, y + 277, 8)
  481.             draw_icon(actor, x + 430, y + 309, 9)
  482.             draw_icon(actor, x + 430, y + 341, 10)
  483.             #Draw parameters bar
  484.             draw_parameter_bar(actor, x + 32, y + 80, width, 1) #HP
  485.             draw_parameter_bar(actor, x + 32, y + 112, width, 2) #SP
  486.             draw_parameter_bar(actor, x + 137, y + 50, width, 3) #EXP
  487.             #Draw Icon Weapon
  488.             draw_parameter_menu(x - 40, y + 280, 22, "Equipments")
  489.             draw_item_icon($data_weapons[actor.weapon_id], x + 10, y + 380) #Weapon
  490.             draw_item_icon($data_armors[actor.armor1_id], x + 85, y + 380) #Shield
  491.             draw_item_icon($data_armors[actor.armor2_id], x + 50, y + 350) #Helmet
  492.             draw_item_icon($data_armors[actor.armor3_id], x + 50, y + 380) #Body Armor
  493.             draw_item_icon($data_armors[actor.armor4_id], x + 50, y + 410) #Accessory
  494.            
  495.         end
  496.     end
  497.     def update_cursor_rect
  498.         if @index < 0
  499.             self.cursor_rect.empty
  500.         else
  501.             self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
  502.         end
  503.     end
  504. end
  505. #=============================================================================
  506. #==============================================================================
  507. # ** Scene_Menu
  508. #------------------------------------------------------------------------------
  509. #  This class performs menu screen processing.
  510. #==============================================================================
  511.  
  512. class Scene_Menu
  513.   #--------------------------------------------------------------------------
  514.   # * Object Initialization
  515.   #     menu_index : command cursor's initial position
  516.   #--------------------------------------------------------------------------
  517.   def initialize(menu_index = 0)
  518.     @menu_index = menu_index
  519.     #----------------------------------------------------
  520.     #Draw_menu_title
  521.     #----------------------------------------------------
  522.     def draw_menu_title(x, y)
  523.         #Draw title text string
  524.         title = "Main Menu"
  525.         self.contents.font.name = "Arial"
  526.         self.contents.font.size = 30
  527.         self.contents.draw_text(x, y, 200, 100, title)
  528.     end
  529.   end
  530.   #--------------------------------------------------------------------------
  531.   # * Main Processing
  532.   #--------------------------------------------------------------------------
  533.   def main
  534.     # Make command window
  535.     s1 = "     " + "Resume" + "  "
  536.     s2 = "     " + $data_system.words.item + " "
  537.     s3 = "     " + $data_system.words.skill + " "
  538.     s4 = "     " + $data_system.words.equip + " "
  539.     s5 = "     " + "Info" + " "
  540.     s6 = "     " + "Mission" + " "
  541.     s7 = "     " + "Save" + " "
  542.     s8 = "     " + "Load" + " "
  543.     s9 = "     " + "Setting" + " "
  544.     s10 = "     " + "Quit" + " "
  545.     @command_window = Window_Command.new(150, [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10])
  546.     @command_window.index = @menu_index
  547.     @command_window.x = 490
  548.     @command_window.y = 50
  549.     # If number of party members is 0
  550.     if $game_party.actors.size == 0
  551.       # Disable items, skills, equipment, and status
  552.       @command_window.disable_item(0)
  553.       @command_window.disable_item(1)
  554.       @command_window.disable_item(2)
  555.       @command_window.disable_item(3)
  556.     end
  557.     # If save is forbidden
  558.     if $game_system.save_disabled
  559.       # Disable save
  560.       @command_window.disable_item(4)
  561.     end
  562.     # Make play time window
  563.     @playtime_window = Window_PlayTime.new
  564.     @playtime_window.x = 480
  565.     @playtime_window.y = 400
  566.     @playtime_window.opacity = 0
  567.     # Make gold window
  568.     @gold_window = Window_Gold.new
  569.     @gold_window.x = 400
  570.     @gold_window.y = 0
  571.     # Make status window
  572.     @status_window = Window_MenuStatus.new
  573.     @status_window.x = 0
  574.     @status_window.y = 0
  575.     # Execute transition
  576.     Graphics.transition
  577.     # Main loop
  578.     loop do
  579.       # Update game screen
  580.       Graphics.update
  581.       # Update input information
  582.       Input.update
  583.       # Frame update
  584.       update
  585.       # Abort loop if screen is changed
  586.       if $scene != self
  587.         break
  588.       end
  589.     end
  590.     # Prepare for transition
  591.     Graphics.freeze
  592.     # Dispose of windows
  593.     @command_window.dispose
  594.     @playtime_window.dispose
  595.     @gold_window.dispose
  596.     @status_window.dispose
  597.   end
  598.   #--------------------------------------------------------------------------
  599.   # * Frame Update
  600.   #--------------------------------------------------------------------------
  601.   def update
  602.     # Update windows
  603.     @command_window.update
  604.     @playtime_window.update
  605.     @gold_window.update
  606.     @status_window.update
  607.     # If command window is active: call update_command
  608.     if @command_window.active
  609.       update_command
  610.       return
  611.     end
  612.     # If status window is active: call update_status
  613.     if @status_window.active
  614.       update_status
  615.       return
  616.     end
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # * Frame Update (when command window is active)
  620.   #--------------------------------------------------------------------------
  621.   def update_command
  622.     # If B button was pressed
  623.     if Input.trigger?(Input::B)
  624.       # Play cancel SE
  625.       $game_system.se_play($data_system.cancel_se)
  626.       # Switch to map screen
  627.       $scene = Scene_Map.new
  628.       return
  629.     end
  630.     # If C button was pressed
  631.     if Input.trigger?(Input::C)
  632.       # If command other than save or end game, and party members = 0
  633.       if $game_party.actors.size == 0 and @command_window.index < 9
  634.         # Play buzzer SE
  635.         $game_system.se_play($data_system.buzzer_se)
  636.         return
  637.       end
  638.       # Branch by command window cursor position
  639.       case @command_window.index
  640.       when 0
  641.         $game_system.se_play($data_system.buzzer_se)
  642.         # Switch to item screen
  643.         $scene = Scene_Map.new
  644.       when 1  # item
  645.         # Play decision SE
  646.         $game_system.se_play($data_system.decision_se)
  647.         # Switch to item screen
  648.         $scene = Scene_Item.new
  649.       when 2  # skill
  650.         # Play decision SE
  651.         $game_system.se_play($data_system.decision_se)
  652.         # Make status window active
  653.         @command_window.active = false
  654.         @status_window.active = true
  655.         $scene = Scene_Skill.new
  656.       when 3  # equipment
  657.         # Play decision SE
  658.         $game_system.se_play($data_system.decision_se)
  659.         # Make status window active
  660.         @command_window.active = false
  661.         @status_window.active = true
  662.         $scene = Scene_Equip.new
  663.       when 4
  664.         $game_system.se_play($data_system.decision_se)
  665.         # Switch to item screen
  666.         $scene = Scene_Info.new
  667.       when 5
  668.         $game_system.se_play($data_system.decision_se)
  669.         # Switch to item screen
  670.         $scene = Scene_Mission.new
  671.       when 6  # save
  672.         if $game_system.save_disabled
  673.           $game_system.se_play($data_system.buzzer_se)
  674.           return
  675.         end
  676.         # Play decision SE
  677.         $game_system.se_play($data_system.decision_se)
  678.         # Switch to save screen
  679.         $scene = Scene_Save.new
  680.       when 7  # load
  681.         if $game_system.save_disabled
  682.           $game_system.se_play($data_system.buzzer_se)
  683.           return
  684.         end
  685.         # Play decision SE
  686.         $game_system.se_play($data_system.decision_se)
  687.         # Switch to load screen
  688.         $scene = Scene_Load.new
  689.       when 8 #Setting
  690.         $game_system.se_play($data_system.decision_se)
  691.         $scene = Scene_Setting.new
  692.       when 9  # end game
  693.         # Play decision SE
  694.         $game_system.se_play($data_system.decision_se)
  695.         # Switch to end game screen
  696.         $scene = Scene_End.new
  697.       end
  698.       return
  699.     end
  700.   end
  701.   #--------------------------------------------------------------------------
  702.   # * Frame Update (when status window is active)
  703.   #--------------------------------------------------------------------------
  704.   def update_status
  705.     # If B button was pressed
  706.     if Input.trigger?(Input::B)
  707.       # Play cancel SE
  708.       $game_system.se_play($data_system.cancel_se)
  709.       # Make command window active
  710.       @command_window.active = true
  711.       @status_window.active = false
  712.       @status_window.index = -1
  713.       return
  714.     end
  715.     # If C button was pressed
  716.     if Input.trigger?(Input::C)
  717.       # Branch by command window cursor position
  718.       case @command_window.index
  719.       when 1  # skill
  720.         # If this actor's action limit is 2 or more
  721.         if $game_party.actors[@status_window.index].restriction >= 2
  722.           # Play buzzer SE
  723.           $game_system.se_play($data_system.buzzer_se)
  724.           return
  725.         end
  726.         # Play decision SE
  727.         $game_system.se_play($data_system.decision_se)
  728.         # Switch to skill screen
  729.         $scene = Scene_Skill.new(@status_window.index)
  730.       when 2  # equipment
  731.         # Play decision SE
  732.         $game_system.se_play($data_system.decision_se)
  733.         # Switch to equipment screen
  734.         $scene = Scene_Equip.new(@status_window.index)
  735.       when 3  # status
  736.         # Play decision SE
  737.         $game_system.se_play($data_system.decision_se)
  738.         # Switch to status screen
  739.         $scene = Scene_Status.new(@status_window.index)
  740.       end
  741.       return
  742.     end
  743.   end
  744. end
  745. #==============================================================================
  746. #==============================================================================
  747. # ** Scene_Item
  748. #------------------------------------------------------------------------------
  749. #  This class performs item screen processing.
  750. #==============================================================================
  751.  
  752. class Scene_Item
  753.   #--------------------------------------------------------------------------
  754.   # * Main Processing
  755.   #--------------------------------------------------------------------------
  756.   def main
  757.     # Make help window, item window
  758.     @help_window = Window_Help.new
  759.     @item_window = Window_Item.new
  760.     # Associate help window
  761.     @item_window.help_window = @help_window
  762.     # Make target window (set to invisible / inactive)
  763.     @target_window = Window_Target.new
  764.     @target_window.visible = false
  765.     @target_window.active = false
  766.     # Execute transition
  767.     Graphics.transition
  768.     # Main loop
  769.     loop do
  770.       # Update game screen
  771.       Graphics.update
  772.       # Update input information
  773.       Input.update
  774.       # Frame update
  775.       update
  776.       # Abort loop if screen is changed
  777.       if $scene != self
  778.         break
  779.       end
  780.     end
  781.     # Prepare for transition
  782.     Graphics.freeze
  783.     # Dispose of windows
  784.     @help_window.dispose
  785.     @item_window.dispose
  786.     @target_window.dispose
  787.   end
  788.   #--------------------------------------------------------------------------
  789.   # * Frame Update
  790.   #--------------------------------------------------------------------------
  791.   def update
  792.     # Update windows
  793.     @help_window.update
  794.     @item_window.update
  795.     @target_window.update
  796.     # If item window is active: call update_item
  797.     if @item_window.active
  798.       update_item
  799.       return
  800.     end
  801.     # If target window is active: call update_target
  802.     if @target_window.active
  803.       update_target
  804.       return
  805.     end
  806.   end
  807.   #--------------------------------------------------------------------------
  808.   # * Frame Update (when item window is active)
  809.   #--------------------------------------------------------------------------
  810.   def update_item
  811.     # If B button was pressed
  812.     if Input.trigger?(Input::B)
  813.       # Play cancel SE
  814.       $game_system.se_play($data_system.cancel_se)
  815.       # Switch to menu screen
  816.       $scene = Scene_Menu.new(1)
  817.       return
  818.     end
  819.     # If C button was pressed
  820.     if Input.trigger?(Input::C)
  821.       # Get currently selected data on the item window
  822.       @item = @item_window.item
  823.       # If not a use item
  824.       unless @item.is_a?(RPG::Item)
  825.         # Play buzzer SE
  826.         $game_system.se_play($data_system.buzzer_se)
  827.         return
  828.       end
  829.       # If it can't be used
  830.       unless $game_party.item_can_use?(@item.id)
  831.         # Play buzzer SE
  832.         $game_system.se_play($data_system.buzzer_se)
  833.         return
  834.       end
  835.       # Play decision SE
  836.       $game_system.se_play($data_system.decision_se)
  837.       # If effect scope is an ally
  838.       if @item.scope >= 3
  839.         # Activate target window
  840.         @item_window.active = false
  841.         @target_window.x = (@item_window.index + 1) % 2 * 304
  842.         @target_window.visible = true
  843.         @target_window.active = true
  844.         # Set cursor position to effect scope (single / all)
  845.         if @item.scope == 4 || @item.scope == 6
  846.           @target_window.index = -1
  847.         else
  848.           @target_window.index = 0
  849.         end
  850.       # If effect scope is other than an ally
  851.       else
  852.         # If command event ID is valid
  853.         if @item.common_event_id > 0
  854.           # Command event call reservation
  855.           $game_temp.common_event_id = @item.common_event_id
  856.           # Play item use SE
  857.           $game_system.se_play(@item.menu_se)
  858.           # If consumable
  859.           if @item.consumable
  860.             # Decrease used items by 1
  861.             $game_party.lose_item(@item.id, 1)
  862.             # Draw item window item
  863.             @item_window.draw_item(@item_window.index)
  864.           end
  865.           # Switch to map screen
  866.           $scene = Scene_Map.new
  867.           return
  868.         end
  869.       end
  870.       return
  871.     end
  872.   end
  873.   #--------------------------------------------------------------------------
  874.   # * Frame Update (when target window is active)
  875.   #--------------------------------------------------------------------------
  876.   def update_target
  877.     # If B button was pressed
  878.     if Input.trigger?(Input::B)
  879.       # Play cancel SE
  880.       $game_system.se_play($data_system.cancel_se)
  881.       # If unable to use because items ran out
  882.       unless $game_party.item_can_use?(@item.id)
  883.         # Remake item window contents
  884.         @item_window.refresh
  885.       end
  886.       # Erase target window
  887.       @item_window.active = true
  888.       @target_window.visible = false
  889.       @target_window.active = false
  890.       return
  891.     end
  892.     # If C button was pressed
  893.     if Input.trigger?(Input::C)
  894.       # If items are used up
  895.       if $game_party.item_number(@item.id) == 0
  896.         # Play buzzer SE
  897.         $game_system.se_play($data_system.buzzer_se)
  898.         return
  899.       end
  900.       # If target is all
  901.       if @target_window.index == -1
  902.         # Apply item effects to entire party
  903.         used = false
  904.         for i in $game_party.actors
  905.           used |= i.item_effect(@item)
  906.         end
  907.       end
  908.       # If single target
  909.       if @target_window.index >= 0
  910.         # Apply item use effects to target actor
  911.         target = $game_party.actors[@target_window.index]
  912.         used = target.item_effect(@item)
  913.       end
  914.       # If an item was used
  915.       if used
  916.         # Play item use SE
  917.         $game_system.se_play(@item.menu_se)
  918.         # If consumable
  919.         if @item.consumable
  920.           # Decrease used items by 1
  921.           $game_party.lose_item(@item.id, 1)
  922.           # Redraw item window item
  923.           @item_window.draw_item(@item_window.index)
  924.         end
  925.         # Remake target window contents
  926.         @target_window.refresh
  927.         # If all party members are dead
  928.         if $game_party.all_dead?
  929.           # Switch to game over screen
  930.           $scene = Scene_Gameover.new
  931.           return
  932.         end
  933.         # If common event ID is valid
  934.         if @item.common_event_id > 0
  935.           # Common event call reservation
  936.           $game_temp.common_event_id = @item.common_event_id
  937.           # Switch to map screen
  938.           $scene = Scene_Map.new
  939.           return
  940.         end
  941.       end
  942.       # If item wasn't used
  943.       unless used
  944.         # Play buzzer SE
  945.         $game_system.se_play($data_system.buzzer_se)
  946.       end
  947.       return
  948.     end
  949.   end
  950. end
  951. #=======================================================================
  952. #==============================================================================
  953. # ** Scene_Skill
  954. #------------------------------------------------------------------------------
  955. #  This class performs skill screen processing.
  956. #==============================================================================
  957.  
  958. class Scene_Skill
  959.   #--------------------------------------------------------------------------
  960.   # * Object Initialization
  961.   #     actor_index : actor index
  962.   #--------------------------------------------------------------------------
  963.   def initialize(actor_index = 0, equip_index = 0)
  964.     @actor_index = actor_index
  965.   end
  966.   #--------------------------------------------------------------------------
  967.   # * Main Processing
  968.   #--------------------------------------------------------------------------
  969.   def main
  970.     # Get actor
  971.     @actor = $game_party.actors[0]
  972.     # Make help window, status window, and skill window
  973.     @help_window = Window_Help.new
  974.     @status_window = Window_SkillStatus.new(@actor)
  975.     @skill_window = Window_Skill.new(@actor)
  976.     # Associate help window
  977.     @skill_window.help_window = @help_window
  978.     # Execute transition
  979.     Graphics.transition
  980.     # Main loop
  981.     loop do
  982.       # Update game screen
  983.       Graphics.update
  984.       # Update input information
  985.       Input.update
  986.       # Frame update
  987.       update
  988.       # Abort loop if screen is changed
  989.       if $scene != self
  990.         break
  991.       end
  992.     end
  993.     # Prepare for transition
  994.     Graphics.freeze
  995.     # Dispose of windows
  996.     @help_window.dispose
  997.     @status_window.dispose
  998.     @skill_window.dispose
  999.   end
  1000.   #--------------------------------------------------------------------------
  1001.   # * Frame Update
  1002.   #--------------------------------------------------------------------------
  1003.   def update
  1004.     # Update windows
  1005.     @help_window.update
  1006.     @status_window.update
  1007.     @skill_window.update
  1008.     # If skill window is active: call update_skill
  1009.     if @skill_window.active
  1010.       update_skill
  1011.       return
  1012.     end
  1013.   end
  1014.   #--------------------------------------------------------------------------
  1015.   # * Frame Update (if skill window is active)
  1016.   #--------------------------------------------------------------------------
  1017.   def update_skill
  1018.     # If B button was pressed
  1019.     if Input.trigger?(Input::B)
  1020.       # Play cancel SE
  1021.       $game_system.se_play($data_system.cancel_se)
  1022.       # Switch to menu screen
  1023.       $scene = Scene_Menu.new(2)
  1024.       return
  1025.     end
  1026.     # If C button was pressed
  1027.     if Input.trigger?(Input::C)
  1028.       # Get currently selected data on the skill window
  1029.       @skill = @skill_window.skill
  1030.       # If unable to use
  1031.       if @skill == nil or not @actor.skill_can_use?(@skill.id)
  1032.         # Play buzzer SE
  1033.         $game_system.se_play($data_system.buzzer_se)
  1034.         return
  1035.       end
  1036.       # Play decision SE
  1037.       $game_system.se_play($data_system.decision_se)
  1038.       # If effect scope is ally
  1039.       if @skill.scope >= 3
  1040.         # Activate target window
  1041.         @skill_window.active = false
  1042.         @target_window.x = (@skill_window.index + 1) % 2 * 304
  1043.         @target_window.visible = true
  1044.         @target_window.active = true
  1045.         # Set cursor position to effect scope (single / all)
  1046.         if @skill.scope == 4 || @skill.scope == 6
  1047.           @target_window.index = -1
  1048.         elsif @skill.scope == 7
  1049.           @target_window.index = @actor_index - 10
  1050.         else
  1051.           @target_window.index = 0
  1052.         end
  1053.       # If effect scope is other than ally
  1054.       else
  1055.         # If common event ID is valid
  1056.         if @skill.common_event_id > 0
  1057.           # Common event call reservation
  1058.           $game_temp.common_event_id = @skill.common_event_id
  1059.           # Play use skill SE
  1060.           $game_system.se_play(@skill.menu_se)
  1061.           # Use up SP
  1062.           @actor.sp -= @skill.sp_cost
  1063.           # Remake each window content
  1064.           @status_window.refresh
  1065.           @skill_window.refresh
  1066.           @target_window.refresh
  1067.           # Switch to map screen
  1068.           $scene = Scene_Map.new
  1069.           return
  1070.         end
  1071.       end
  1072.       return
  1073.     end
  1074.   end
  1075.   #--------------------------------------------------------------------------
  1076.   # * Frame Update (when target window is active)
  1077.   #--------------------------------------------------------------------------
  1078.   def update_target
  1079.     # If B button was pressed
  1080.     if Input.trigger?(Input::B)
  1081.       # Play cancel SE
  1082.       $game_system.se_play($data_system.cancel_se)
  1083.       # Erase target window
  1084.       @skill_window.active = true
  1085.       @target_window.visible = false
  1086.       @target_window.active = false
  1087.       return
  1088.     end
  1089.     # If C button was pressed
  1090.     if Input.trigger?(Input::C)
  1091.       # If unable to use because SP ran out
  1092.       unless @actor.skill_can_use?(@skill.id)
  1093.         # Play buzzer SE
  1094.         $game_system.se_play($data_system.buzzer_se)
  1095.         return
  1096.       end
  1097.       # If target is all
  1098.       if @target_window.index == -1
  1099.         # Apply skill use effects to entire party
  1100.         used = false
  1101.         for i in $game_party.actors
  1102.           used |= i.skill_effect(@actor, @skill)
  1103.         end
  1104.       end
  1105.       # If target is user
  1106.       if @target_window.index <= -2
  1107.         # Apply skill use effects to target actor
  1108.         target = $game_party.actors[@target_window.index + 10]
  1109.         used = target.skill_effect(@actor, @skill)
  1110.       end
  1111.       # If single target
  1112.       if @target_window.index >= 0
  1113.         # Apply skill use effects to target actor
  1114.         target = $game_party.actors[@target_window.index]
  1115.         used = target.skill_effect(@actor, @skill)
  1116.       end
  1117.       # If skill was used
  1118.       if used
  1119.         # Play skill use SE
  1120.         $game_system.se_play(@skill.menu_se)
  1121.         # Use up SP
  1122.         @actor.sp -= @skill.sp_cost
  1123.         # Remake each window content
  1124.         @status_window.refresh
  1125.         @skill_window.refresh
  1126.         @target_window.refresh
  1127.         # If entire party is dead
  1128.         if $game_party.all_dead?
  1129.           # Switch to game over screen
  1130.           $scene = Scene_Gameover.new
  1131.           return
  1132.         end
  1133.         # If command event ID is valid
  1134.         if @skill.common_event_id > 0
  1135.           # Command event call reservation
  1136.           $game_temp.common_event_id = @skill.common_event_id
  1137.           # Switch to map screen
  1138.           $scene = Scene_Map.new
  1139.           return
  1140.         end
  1141.       end
  1142.       # If skill wasn't used
  1143.       unless used
  1144.         # Play buzzer SE
  1145.         $game_system.se_play($data_system.buzzer_se)
  1146.       end
  1147.       return
  1148.     end
  1149.   end
  1150. end
  1151. #========================================================================
  1152. #==============================================================================
  1153. # ** Scene_Equip
  1154. #------------------------------------------------------------------------------
  1155. #  This class performs equipment screen processing.
  1156. #==============================================================================
  1157.  
  1158. class Scene_Equip
  1159.   #--------------------------------------------------------------------------
  1160.   # * Object Initialization
  1161.   #     actor_index : actor index
  1162.   #     equip_index : equipment index
  1163.   #--------------------------------------------------------------------------
  1164.   def initialize(actor_index = 0, equip_index = 0)
  1165.     @actor_index = actor_index
  1166.     @equip_index = equip_index
  1167.   end
  1168.   #--------------------------------------------------------------------------
  1169.   # * Main Processing
  1170.   #--------------------------------------------------------------------------
  1171.   def main
  1172.     # Get actor
  1173.     @actor = $game_party.actors[@actor_index]
  1174.     # Make windows
  1175.     @help_window = Window_Help.new
  1176.     @left_window = Window_EquipLeft.new(@actor)
  1177.     @right_window = Window_EquipRight.new(@actor)
  1178.     @item_window1 = Window_EquipItem.new(@actor, 0)
  1179.     @item_window2 = Window_EquipItem.new(@actor, 1)
  1180.     @item_window3 = Window_EquipItem.new(@actor, 2)
  1181.     @item_window4 = Window_EquipItem.new(@actor, 3)
  1182.     @item_window5 = Window_EquipItem.new(@actor, 4)
  1183.     # Associate help window
  1184.     @right_window.help_window = @help_window
  1185.     @item_window1.help_window = @help_window
  1186.     @item_window2.help_window = @help_window
  1187.     @item_window3.help_window = @help_window
  1188.     @item_window4.help_window = @help_window
  1189.     @item_window5.help_window = @help_window
  1190.     # Set cursor position
  1191.     @right_window.index = @equip_index
  1192.     refresh
  1193.     # Execute transition
  1194.     Graphics.transition
  1195.     # Main loop
  1196.     loop do
  1197.       # Update game screen
  1198.       Graphics.update
  1199.       # Update input information
  1200.       Input.update
  1201.       # Frame update
  1202.       update
  1203.       # Abort loop if screen is changed
  1204.       if $scene != self
  1205.         break
  1206.       end
  1207.     end
  1208.     # Prepare for transition
  1209.     Graphics.freeze
  1210.     # Dispose of windows
  1211.     @help_window.dispose
  1212.     @left_window.dispose
  1213.     @right_window.dispose
  1214.     @item_window1.dispose
  1215.     @item_window2.dispose
  1216.     @item_window3.dispose
  1217.     @item_window4.dispose
  1218.     @item_window5.dispose
  1219.   end
  1220.   #--------------------------------------------------------------------------
  1221.   # * Refresh
  1222.   #--------------------------------------------------------------------------
  1223.   def refresh
  1224.     # Set item window to visible
  1225.     @item_window1.visible = (@right_window.index == 0)
  1226.     @item_window2.visible = (@right_window.index == 1)
  1227.     @item_window3.visible = (@right_window.index == 2)
  1228.     @item_window4.visible = (@right_window.index == 3)
  1229.     @item_window5.visible = (@right_window.index == 4)
  1230.     # Get currently equipped item
  1231.     item1 = @right_window.item
  1232.     # Set current item window to @item_window
  1233.     case @right_window.index
  1234.     when 0
  1235.       @item_window = @item_window1
  1236.     when 1
  1237.       @item_window = @item_window2
  1238.     when 2
  1239.       @item_window = @item_window3
  1240.     when 3
  1241.       @item_window = @item_window4
  1242.     when 4
  1243.       @item_window = @item_window5
  1244.     end
  1245.     # If right window is active
  1246.     if @right_window.active
  1247.       # Erase parameters for after equipment change
  1248.       @left_window.set_new_parameters(nil, nil, nil)
  1249.     end
  1250.     # If item window is active
  1251.     if @item_window.active
  1252.       # Get currently selected item
  1253.       item2 = @item_window.item
  1254.       # Change equipment
  1255.       last_hp = @actor.hp
  1256.       last_sp = @actor.sp
  1257.       @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
  1258.       # Get parameters for after equipment change
  1259.       new_atk = @actor.atk
  1260.       new_pdef = @actor.pdef
  1261.       new_mdef = @actor.mdef
  1262.       # Return equipment
  1263.       @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
  1264.       @actor.hp = last_hp
  1265.       @actor.sp = last_sp
  1266.       # Draw in left window
  1267.       @left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
  1268.     end
  1269.   end
  1270.   #--------------------------------------------------------------------------
  1271.   # * Frame Update
  1272.   #--------------------------------------------------------------------------
  1273.   def update
  1274.     # Update windows
  1275.     @left_window.update
  1276.     @right_window.update
  1277.     @item_window.update
  1278.     refresh
  1279.     # If right window is active: call update_right
  1280.     if @right_window.active
  1281.       update_right
  1282.       return
  1283.     end
  1284.     # If item window is active: call update_item
  1285.     if @item_window.active
  1286.       update_item
  1287.       return
  1288.     end
  1289.   end
  1290.   #--------------------------------------------------------------------------
  1291.   # * Frame Update (when right window is active)
  1292.   #--------------------------------------------------------------------------
  1293.   def update_right
  1294.     # If B button was pressed
  1295.     if Input.trigger?(Input::B)
  1296.       # Play cancel SE
  1297.       $game_system.se_play($data_system.cancel_se)
  1298.       # Switch to menu screen
  1299.       $scene = Scene_Menu.new(3)
  1300.       return
  1301.     end
  1302.     # If C button was pressed
  1303.     if Input.trigger?(Input::C)
  1304.       # If equipment is fixed
  1305.       if @actor.equip_fix?(@right_window.index)
  1306.         # Play buzzer SE
  1307.         $game_system.se_play($data_system.buzzer_se)
  1308.         return
  1309.       end
  1310.       # Play decision SE
  1311.       $game_system.se_play($data_system.decision_se)
  1312.       # Activate item window
  1313.       @right_window.active = false
  1314.       @item_window.active = true
  1315.       @item_window.index = 0
  1316.       return
  1317.     end
  1318.     # If R button was pressed
  1319.     if Input.trigger?(Input::R)
  1320.       # Play cursor SE
  1321.       $game_system.se_play($data_system.cursor_se)
  1322.       # To next actor
  1323.       @actor_index += 1
  1324.       @actor_index %= $game_party.actors.size
  1325.       # Switch to different equipment screen
  1326.       $scene = Scene_Equip.new(@actor_index, @right_window.index)
  1327.       return
  1328.     end
  1329.     # If L button was pressed
  1330.     if Input.trigger?(Input::L)
  1331.       # Play cursor SE
  1332.       $game_system.se_play($data_system.cursor_se)
  1333.       # To previous actor
  1334.       @actor_index += $game_party.actors.size - 1
  1335.       @actor_index %= $game_party.actors.size
  1336.       # Switch to different equipment screen
  1337.       $scene = Scene_Equip.new(@actor_index, @right_window.index)
  1338.       return
  1339.     end
  1340.   end
  1341.   #--------------------------------------------------------------------------
  1342.   # * Frame Update (when item window is active)
  1343.   #--------------------------------------------------------------------------
  1344.   def update_item
  1345.     # If B button was pressed
  1346.     if Input.trigger?(Input::B)
  1347.       # Play cancel SE
  1348.       $game_system.se_play($data_system.cancel_se)
  1349.       # Activate right window
  1350.       @right_window.active = true
  1351.       @item_window.active = false
  1352.       @item_window.index = -1
  1353.       return
  1354.     end
  1355.     # If C button was pressed
  1356.     if Input.trigger?(Input::C)
  1357.       # Play equip SE
  1358.       $game_system.se_play($data_system.equip_se)
  1359.       # Get currently selected data on the item window
  1360.       item = @item_window.item
  1361.       # Change equipment
  1362.       @actor.equip(@right_window.index, item == nil ? 0 : item.id)
  1363.       # Activate right window
  1364.       @right_window.active = true
  1365.       @item_window.active = false
  1366.       @item_window.index = -1
  1367.       # Remake right window and item window contents
  1368.       @right_window.refresh
  1369.       @item_window.refresh
  1370.       return
  1371.     end
  1372.   end
  1373. end
  1374. #=============================================================================
  1375. #==============================================================================
  1376. # ** Scene_Save
  1377. #------------------------------------------------------------------------------
  1378. #  This class performs save screen processing.
  1379. #==============================================================================
  1380.  
  1381. class Scene_Save < Scene_File
  1382.   #--------------------------------------------------------------------------
  1383.   # * Object Initialization
  1384.   #--------------------------------------------------------------------------
  1385.   def initialize
  1386.     super("Which file would you like to save to?")
  1387.   end
  1388.   #--------------------------------------------------------------------------
  1389.   # * Decision Processing
  1390.   #--------------------------------------------------------------------------
  1391.   def on_decision(filename)
  1392.     # Play save SE
  1393.     $game_system.se_play($data_system.save_se)
  1394.     # Write save data
  1395.     file = File.open(filename, "wb")
  1396.     write_save_data(file)
  1397.     file.close
  1398.     # If called from event
  1399.     if $game_temp.save_calling
  1400.       # Clear save call flag
  1401.       $game_temp.save_calling = false
  1402.       # Switch to map screen
  1403.       $scene = Scene_Map.new
  1404.       return
  1405.     end
  1406.     # Switch to menu screen
  1407.     $scene = Scene_Menu.new(4)
  1408.   end
  1409.   #--------------------------------------------------------------------------
  1410.   # * Cancel Processing
  1411.   #--------------------------------------------------------------------------
  1412.   def on_cancel
  1413.     # Play cancel SE
  1414.     $game_system.se_play($data_system.cancel_se)
  1415.     # If called from event
  1416.     if $game_temp.save_calling
  1417.       # Clear save call flag
  1418.       $game_temp.save_calling = false
  1419.       # Switch to map screen
  1420.       $scene = Scene_Map.new
  1421.       return
  1422.     end
  1423.     # Switch to menu screen
  1424.     $scene = Scene_Menu.new(6)
  1425.   end
  1426.   #--------------------------------------------------------------------------
  1427.   # * Write Save Data
  1428.   #     file : write file object (opened)
  1429.   #--------------------------------------------------------------------------
  1430.   def write_save_data(file)
  1431.     # Make character data for drawing save file
  1432.     characters = []
  1433.     for i in 0...$game_party.actors.size
  1434.       actor = $game_party.actors[i]
  1435.       characters.push([actor.character_name, actor.character_hue])
  1436.     end
  1437.     # Write character data for drawing save file
  1438.     Marshal.dump(characters, file)
  1439.     # Wrire frame count for measuring play time
  1440.     Marshal.dump(Graphics.frame_count, file)
  1441.     # Increase save count by 1
  1442.     $game_system.save_count += 1
  1443.     # Save magic number
  1444.     # (A random value will be written each time saving with editor)
  1445.     $game_system.magic_number = $data_system.magic_number
  1446.     # Write each type of game object
  1447.     Marshal.dump($game_system, file)
  1448.     Marshal.dump($game_switches, file)
  1449.     Marshal.dump($game_variables, file)
  1450.     Marshal.dump($game_self_switches, file)
  1451.     Marshal.dump($game_screen, file)
  1452.     Marshal.dump($game_actors, file)
  1453.     Marshal.dump($game_party, file)
  1454.     Marshal.dump($game_troop, file)
  1455.     Marshal.dump($game_map, file)
  1456.     Marshal.dump($game_player, file)
  1457.   end
  1458. end
  1459. #=======================================================================
  1460. #==============================================================================
  1461. # ** Scene_Load
  1462. #------------------------------------------------------------------------------
  1463. #  This class performs load screen processing.
  1464. #==============================================================================
  1465.  
  1466. class Scene_Load < Scene_File
  1467.   #--------------------------------------------------------------------------
  1468.   # * Object Initialization
  1469.   #--------------------------------------------------------------------------
  1470.   def initialize
  1471.     # Remake temporary object
  1472.     $game_temp = Game_Temp.new
  1473.     # Timestamp selects new file
  1474.     $game_temp.last_file_index = 0
  1475.     latest_time = Time.at(0)
  1476.     for i in 0..3
  1477.       filename = make_filename(i)
  1478.       if FileTest.exist?(filename)
  1479.         file = File.open(filename, "r")
  1480.         if file.mtime > latest_time
  1481.           latest_time = file.mtime
  1482.           $game_temp.last_file_index = i
  1483.         end
  1484.         file.close
  1485.       end
  1486.     end
  1487.     super("Which file would you like to load?")
  1488.   end
  1489.   #--------------------------------------------------------------------------
  1490.   # * Decision Processing
  1491.   #--------------------------------------------------------------------------
  1492.   def on_decision(filename)
  1493.     # If file doesn't exist
  1494.     unless FileTest.exist?(filename)
  1495.       # Play buzzer SE
  1496.       $game_system.se_play($data_system.buzzer_se)
  1497.       return
  1498.     end
  1499.     # Play load SE
  1500.     $game_system.se_play($data_system.load_se)
  1501.     # Read save data
  1502.     file = File.open(filename, "rb")
  1503.     read_save_data(file)
  1504.     file.close
  1505.     # Restore BGM and BGS
  1506.     $game_system.bgm_play($game_system.playing_bgm)
  1507.     $game_system.bgs_play($game_system.playing_bgs)
  1508.     # Update map (run parallel process event)
  1509.     $game_map.update
  1510.     # Switch to map screen
  1511.     $scene = Scene_Map.new
  1512.   end
  1513.   #--------------------------------------------------------------------------
  1514.   # * Cancel Processing
  1515.   #--------------------------------------------------------------------------
  1516.   def on_cancel
  1517.     # Play cancel SE
  1518.     $game_system.se_play($data_system.cancel_se)
  1519.     # Switch to title screen
  1520.     $scene = Scene_Menu.new(7)
  1521.   end
  1522.   #--------------------------------------------------------------------------
  1523.   # * Read Save Data
  1524.   #     file : file object for reading (opened)
  1525.   #--------------------------------------------------------------------------
  1526.   def read_save_data(file)
  1527.     # Read character data for drawing save file
  1528.     characters = Marshal.load(file)
  1529.     # Read frame count for measuring play time
  1530.     Graphics.frame_count = Marshal.load(file)
  1531.     # Read each type of game object
  1532.     $game_system        = Marshal.load(file)
  1533.     $game_switches      = Marshal.load(file)
  1534.     $game_variables     = Marshal.load(file)
  1535.     $game_self_switches = Marshal.load(file)
  1536.     $game_screen        = Marshal.load(file)
  1537.     $game_actors        = Marshal.load(file)
  1538.     $game_party         = Marshal.load(file)
  1539.     $game_troop         = Marshal.load(file)
  1540.     $game_map           = Marshal.load(file)
  1541.     $game_player        = Marshal.load(file)
  1542.     # If magic number is different from when saving
  1543.     # (if editing was added with editor)
  1544.     if $game_system.magic_number != $data_system.magic_number
  1545.       # Load map
  1546.       $game_map.setup($game_map.map_id)
  1547.       $game_player.center($game_player.x, $game_player.y)
  1548.     end
  1549.     # Refresh party members
  1550.     $game_party.refresh
  1551.   end
  1552. end
  1553.    
  1554. #==============================================================================
  1555. # ** Scene_End
  1556. #------------------------------------------------------------------------------
  1557. #  This class performs game end screen processing.
  1558. #==============================================================================
  1559.  
  1560. class Scene_End
  1561.   #--------------------------------------------------------------------------
  1562.   # * Main Processing
  1563.   #--------------------------------------------------------------------------
  1564.   def main
  1565.     # Make command window
  1566.     s1 = "To Title"
  1567.     s2 = "Shutdown"
  1568.     s3 = "Cancel"
  1569.     @command_window = Window_Command.new(192, [s1, s2, s3])
  1570.     @command_window.x = 320 - @command_window.width / 2
  1571.     @command_window.y = 240 - @command_window.height / 2
  1572.     # Execute transition
  1573.     Graphics.transition
  1574.     # Main loop
  1575.     loop do
  1576.       # Update game screen
  1577.       Graphics.update
  1578.       # Update input information
  1579.       Input.update
  1580.       # Frame Update
  1581.       update
  1582.       # Abort loop if screen is changed
  1583.       if $scene != self
  1584.         break
  1585.       end
  1586.     end
  1587.     # Prepare for transition
  1588.     Graphics.freeze
  1589.     # Dispose of window
  1590.     @command_window.dispose
  1591.     # If switching to title screen
  1592.     if $scene.is_a?(Scene_Title)
  1593.       # Fade out screen
  1594.       Graphics.transition
  1595.       Graphics.freeze
  1596.     end
  1597.   end
  1598.   #--------------------------------------------------------------------------
  1599.   # * Frame Update
  1600.   #--------------------------------------------------------------------------
  1601.   def update
  1602.     # Update command window
  1603.     @command_window.update
  1604.     # If B button was pressed
  1605.     if Input.trigger?(Input::B)
  1606.       # Play cancel SE
  1607.       $game_system.se_play($data_system.cancel_se)
  1608.       # Switch to menu screen
  1609.       $scene = Scene_Menu.new(9)
  1610.       return
  1611.     end
  1612.     # If C button was pressed
  1613.     if Input.trigger?(Input::C)
  1614.       # Branch by command window cursor position
  1615.       case @command_window.index
  1616.       when 0  # to title
  1617.         command_to_title
  1618.       when 1  # shutdown
  1619.         command_shutdown
  1620.       when 2  # quit
  1621.         command_cancel
  1622.       end
  1623.       return
  1624.     end
  1625.   end
  1626.   #--------------------------------------------------------------------------
  1627.   # * Process When Choosing [To Title] Command
  1628.   #--------------------------------------------------------------------------
  1629.   def command_to_title
  1630.     # Play decision SE
  1631.     $game_system.se_play($data_system.decision_se)
  1632.     # Fade out BGM, BGS, and ME
  1633.     Audio.bgm_fade(800)
  1634.     Audio.bgs_fade(800)
  1635.     Audio.me_fade(800)
  1636.     # Switch to title screen
  1637.     $scene = Scene_Title.new
  1638.   end
  1639.   #--------------------------------------------------------------------------
  1640.   # * Process When Choosing [Shutdown] Command
  1641.   #--------------------------------------------------------------------------
  1642.   def command_shutdown
  1643.     # Play decision SE
  1644.     $game_system.se_play($data_system.decision_se)
  1645.     # Fade out BGM, BGS, and ME
  1646.     Audio.bgm_fade(800)
  1647.     Audio.bgs_fade(800)
  1648.     Audio.me_fade(800)
  1649.     # Shutdown
  1650.     $scene = nil
  1651.   end
  1652.   #--------------------------------------------------------------------------
  1653.   # *  Process When Choosing [Cancel] Command
  1654.   #--------------------------------------------------------------------------
  1655.   def command_cancel
  1656.     # Play decision SE
  1657.     $game_system.se_play($data_system.decision_se)
  1658.     # Switch to menu screen
  1659.     $scene = Scene_Menu.new(5)
  1660.   end
  1661. end
  1662. #=============================================================================
  1663. #==============================================================================
  1664. # ** Scene_File
  1665. #------------------------------------------------------------------------------
  1666. #  This is a superclass for the save screen and load screen.
  1667. #==============================================================================
  1668.  
  1669. class Scene_File
  1670.   #--------------------------------------------------------------------------
  1671.   # * Object Initialization
  1672.   #     help_text : text string shown in the help window
  1673.   #--------------------------------------------------------------------------
  1674.   def initialize(help_text)
  1675.     @help_text = help_text
  1676.   end
  1677.   #--------------------------------------------------------------------------
  1678.   # * Main Processing
  1679.   #--------------------------------------------------------------------------
  1680.   def main
  1681.     # Make help window
  1682.     @help_window = Window_Help.new
  1683.     @help_window.set_text(@help_text)
  1684.     # Make save file window
  1685.     @savefile_windows = []
  1686.     for i in 0..3
  1687.       @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
  1688.     end
  1689.     # Select last file to be operated
  1690.     @file_index = $game_temp.last_file_index
  1691.     @savefile_windows[@file_index].selected = true
  1692.     # Execute transition
  1693.     Graphics.transition
  1694.     # Main loop
  1695.     loop do
  1696.       # Update game screen
  1697.       Graphics.update
  1698.       # Update input information
  1699.       Input.update
  1700.       # Frame update
  1701.       update
  1702.       # Abort loop if screen is changed
  1703.       if $scene != self
  1704.         break
  1705.       end
  1706.     end
  1707.     # Prepare for transition
  1708.     Graphics.freeze
  1709.     # Dispose of windows
  1710.     @help_window.dispose
  1711.     for i in @savefile_windows
  1712.       i.dispose
  1713.     end
  1714.   end
  1715.   #--------------------------------------------------------------------------
  1716.   # * Frame Update
  1717.   #--------------------------------------------------------------------------
  1718.   def update
  1719.     # Update windows
  1720.     @help_window.update
  1721.     for i in @savefile_windows
  1722.       i.update
  1723.     end
  1724.     # If C button was pressed
  1725.     if Input.trigger?(Input::C)
  1726.       # Call method: on_decision (defined by the subclasses)
  1727.       on_decision(make_filename(@file_index))
  1728.       $game_temp.last_file_index = @file_index
  1729.       return
  1730.     end
  1731.     # If B button was pressed
  1732.     if Input.trigger?(Input::B)
  1733.       # Call method: on_cancel (defined by the subclasses)
  1734.       on_cancel
  1735.       return
  1736.     end
  1737.     # If the down directional button was pressed
  1738.     if Input.repeat?(Input::DOWN)
  1739.       # If the down directional button pressed down is not a repeat,
  1740.       # or cursor position is more in front than 3
  1741.       if Input.trigger?(Input::DOWN) or @file_index < 3
  1742.         # Play cursor SE
  1743.         $game_system.se_play($data_system.cursor_se)
  1744.         # Move cursor down
  1745.         @savefile_windows[@file_index].selected = false
  1746.         @file_index = (@file_index + 1) % 4
  1747.         @savefile_windows[@file_index].selected = true
  1748.         return
  1749.       end
  1750.     end
  1751.     # If the up directional button was pressed
  1752.     if Input.repeat?(Input::UP)
  1753.       # If the up directional button pressed down is not a repeat、
  1754.       # or cursor position is more in back than 0
  1755.       if Input.trigger?(Input::UP) or @file_index > 0
  1756.         # Play cursor SE
  1757.         $game_system.se_play($data_system.cursor_se)
  1758.         # Move cursor up
  1759.         @savefile_windows[@file_index].selected = false
  1760.         @file_index = (@file_index + 3) % 4
  1761.         @savefile_windows[@file_index].selected = true
  1762.         return
  1763.       end
  1764.     end
  1765.   end
  1766.   #--------------------------------------------------------------------------
  1767.   # * Make File Name
  1768.   #     file_index : save file index (0-3)
  1769.   #--------------------------------------------------------------------------
  1770.   def make_filename(file_index)
  1771.     return "Save#{file_index + 1}.rxdata"
  1772.   end
  1773. end
  1774. #===============================================================================