Advertisement
mjshi

One Player Menusystem

Jul 8th, 2015
1,033
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 35.69 KB | None | 0 0
  1. #==============================================================================#
  2. # Script by: Tigurus Fay, edit by mjshi                                        #
  3. # Requires: None                                                               #
  4. #==============================================================================#
  5. # Script: One-Player Menu Script                                               #
  6. # Version: v1.2.2,                                                             #
  7. # Install: Press F11 and place the Script directly above [Main].               #
  8. # Description: This script allows a menu optimized for 1 player only.          #
  9. #==============================================================================#
  10.  
  11.   class Game_Actor < Game_Battler
  12.     def now_exp
  13.       return @exp - @exp_list[@level]
  14.     end
  15.     def next_exp
  16.       return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : @exp_list[@level]  
  17.     end
  18.   end
  19.  
  20.   def draw_actor_barz(actor,x, y, type, length, thick, e1, e2, c1 = Color.new(255,0,0,255), c2 = Color.new(0,0,0,255))
  21.     if type == "horizontal"
  22.       width = length
  23.       height = thick
  24.       self.contents.fill_rect(x-1, y - 1, width + 1, height + 3, Color.new(0, 0, 0, 255))
  25.       self.contents.fill_rect(x, y, width + 1, height + 1, Color.new(0, 0, 0, 255))
  26.       w = width * e1.to_f / e2.to_f
  27.       for i in 0..height
  28.       r = c1.red + (c2.red - c1.red) * (height -i)/height + 0 * i/height
  29.       g = c1.green + (c2.green - c1.green) * (height -i)/height + 0 * i/height
  30.       b = c1.blue + (c2.blue - c1.blue) * (height -i)/height + 0 * i/height
  31.       a = c1.alpha + (c2.alpha - c1.alpha)* (height -i)/height + 255 * i/height
  32.       self.contents.fill_rect(x, y+i, w, 1, Color.new(r, g, b, a))
  33.     end
  34.   end
  35. end
  36.  
  37.   def draw_actor_battler(actor, x, y)
  38.     bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  39.     cw = bitmap.width
  40.     ch = bitmap.height
  41.     src_rect = Rect.new(0, 0, cw, ch)
  42.   self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  43. end  
  44. #==============================================================================
  45. # ** Game_Map
  46. #------------------------------------------------------------------------------
  47. #  This window will allow the use of locations on the menu
  48. #==============================================================================
  49.  
  50. class Game_Map
  51.   attr_reader   :map_id  
  52.   def mpname
  53.     $mpname = load_data("Data/MapInfos.rxdata")
  54.     $mpname[@map_id].name
  55.   end
  56. end
  57. #==============================================================================
  58. # ** Window_Base
  59. #------------------------------------------------------------------------------
  60. #  This class is for all in-game windows.
  61. #==============================================================================
  62.  
  63. class Window_Base < Window
  64.   #--------------------------------------------------------------------------
  65.   # * Draw EXP
  66.   #     actor : actor
  67.   #     x     : draw spot x-coordinate24
  68.   #     y     : draw spot y-coordinate
  69.   #--------------------------------------------------------------------------
  70.   def draw_actor_exp(actor, x, y)
  71.     self.contents.font.color = system_color
  72.     self.contents.draw_text(x, y, 84, 32, "Experience")
  73.     self.contents.font.color = normal_color
  74.     self.contents.draw_text(x + 68, y, 74, 32, actor.exp_s, 2)
  75.     self.contents.draw_text(x + 142, y, 12, 32, "/", 1)
  76.     self.contents.draw_text(x + 154, y, 74, 32, actor.next_exp_s)
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # * Draw HP
  80.   #     actor : actor
  81.   #     x     : draw spot x-coordinate
  82.   #     y     : draw spot y-coordinate
  83.   #     width : draw spot width
  84.   #--------------------------------------------------------------------------
  85.   def draw_actor_health(actor, x, y, width = 144)
  86.     # Draw "HP" text string
  87.     self.contents.font.color = system_color
  88.     self.contents.draw_text(x, y, 84, 32, $data_system.words.hp)
  89.     # Calculate if there is draw space for MaxHP
  90.     if width - 32 >= 108
  91.       hp_x = x + width - 50
  92.       flag = true
  93.     elsif width - 32 >= 48
  94.       hp_x = x + width - 48
  95.       flag = false
  96.     end
  97.     # Draw HP
  98.     self.contents.font.color = actor.hp == 0 ? knockout_color :
  99.       actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  100.     self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
  101.     # Draw MaxHP
  102.     if flag
  103.       self.contents.font.color = normal_color
  104.       self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
  105.       self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
  106.     end
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # * Draw SP
  110.   #     actor : actor
  111.   #     x     : draw spot x-coordinate
  112.   #     y     : draw spot y-coordinate
  113.   #     width : draw spot width
  114.   #--------------------------------------------------------------------------
  115.   def draw_actor_mana(actor, x, y, width = 144)
  116.     # Draw "SP" text string
  117.     self.contents.font.color = system_color
  118.     self.contents.draw_text(x, y, 84, 32, $data_system.words.sp)
  119.     # Calculate if there is draw space for MaxHP
  120.     if width - 32 >= 108
  121.       sp_x = x + width - 50
  122.       flag = true
  123.     elsif width - 32 >= 48
  124.       sp_x = x + width - 48
  125.       flag = false
  126.     end
  127.     # Draw SP
  128.     self.contents.font.color = actor.sp == 0 ? knockout_color :
  129.       actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  130.     self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
  131.     # Draw MaxSP
  132.     if flag
  133.       self.contents.font.color = normal_color
  134.       self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
  135.       self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
  136.     end
  137.   end
  138. end
  139.  
  140. #==============================================================================
  141. # ** Window_Avatar
  142. #------------------------------------------------------------------------------
  143. #  This window displays the Battler on Scene_Menu
  144. #==============================================================================
  145.  
  146. class Window_Avatar < Window_Base
  147.  
  148.   def initialize
  149.     super(0, 0, 320, 192)
  150.     self.contents = Bitmap.new(width - 32, height - 32)
  151.     refresh
  152.   end
  153.  
  154.   def refresh
  155.     self.contents.clear
  156.     @item_max = $game_party.actors.size
  157.     for i in 0...$game_party.actors.size
  158.      actor = $game_party.actors[0]
  159.      draw_actor_battler(actor, x + 220, y + 165)
  160.     end
  161.    end
  162.  end
  163.  
  164. #==============================================================================
  165. # ** Window_Mapname
  166. #------------------------------------------------------------------------------
  167. #  This window displays the name of the map.
  168. #==============================================================================
  169.  
  170. class Window_Mapname < Window_Base
  171.   def initialize
  172.     super(0, 0, 160, 96)
  173.     self.contents = Bitmap.new(width - 32, height - 32)
  174.     self.contents.font.name = "Arial"
  175.     self.contents.font.size = 22
  176.     refresh
  177.   end
  178.  
  179.   def refresh
  180.     self.contents.clear
  181.     self.contents.font.color = system_color
  182.     lx = contents.text_size("Location").width
  183.     self.contents.draw_text(4, -55, lx, 144, "Location", 1)
  184.     self.contents.font.color = normal_color
  185.     self.contents.font.size = 20
  186.     self.contents.draw_text(0, 0, 110, 106, $game_map.mpname.to_s)
  187.     bitmap = RPG::Cache.icon("038-Item07")
  188.     self.contents.blt(105, 40, bitmap, Rect.new(0, 0, 24, 24))
  189.   end
  190. end
  191.  
  192. #==============================================================================
  193. # ** Window_Gold
  194. #------------------------------------------------------------------------------
  195. #  This window displays amount of gold.
  196. #==============================================================================
  197.  
  198. class Window_Gold < Window_Base
  199.  
  200.   def initialize
  201.     super(0, 0, 160, 96)
  202.     self.contents = Bitmap.new(width - 32, height - 32)
  203.     refresh
  204.   end
  205.  
  206.   def refresh
  207.     self.contents.clear
  208.     cx = contents.text_size($data_system.words.gold).width
  209.     self.contents.font.color = system_color
  210.     self.contents.draw_text(4, 0, 120, 32, "Gold", 30)
  211.     self.contents.font.color = normal_color
  212.     self.contents.draw_text(4, 0, 90-cx-2, 106, $game_party.gold.to_s, 2)
  213.     self.contents.font.color = system_color
  214.     self.contents.draw_text(94-cx, 0, cx, 106, $data_system.words.gold, 2)
  215.     bitmap = RPG::Cache.icon("032-Item01")
  216.     self.contents.blt(105, 40, bitmap, Rect.new(0, 0, 24, 24))
  217.   end
  218. end
  219.  
  220. #==============================================================================
  221. # ** Window_PlayTime
  222. #------------------------------------------------------------------------------
  223. #  This window displays play time on the menu screen.
  224. #==============================================================================
  225.  
  226. class Window_PlayTime < Window_Base
  227.  
  228.   def initialize
  229.     super(0, 0, 160, 96)
  230.     self.contents = Bitmap.new(width - 32, height - 32)
  231.     refresh
  232.   end
  233.  
  234.   def refresh
  235.     self.contents.clear
  236.     self.contents.font.color = system_color
  237.     self.contents.draw_text(4, 0, 120, 32, "Play Time")
  238.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  239.     hour = @total_sec / 60 / 60
  240.     min = @total_sec / 60 % 60
  241.     sec = @total_sec % 60
  242.     text = sprintf("%02d:%02d:%02d", hour, min, sec)
  243.     self.contents.font.color = normal_color
  244.     self.contents.draw_text(4, 32, 96, 40, text, 2)
  245.     bitmap = RPG::Cache.icon("037-Item06")
  246.     self.contents.blt(105, 40, bitmap, Rect.new(0, 0, 24, 24))
  247.   end
  248.  
  249.   def update
  250.     super
  251.     if Graphics.frame_count / Graphics.frame_rate != @total_sec
  252.       refresh
  253.     end
  254.   end
  255. end
  256.  
  257. #==============================================================================
  258. # ** Window_Steps
  259. #------------------------------------------------------------------------------
  260. #  This window displays step count on the menu screen.
  261. #==============================================================================
  262.  
  263. class Window_Steps < Window_Base
  264.  
  265.   def initialize
  266.     super(0, 0, 160, 96)
  267.     self.contents = Bitmap.new(width - 32, height - 32)
  268.     refresh
  269.   end
  270.  
  271.   def refresh
  272.     self.contents.clear
  273.     self.contents.font.color = system_color
  274.     self.contents.draw_text(4, 0, 120, 32, "Step Count")
  275.     self.contents.font.color = normal_color
  276.     self.contents.draw_text(4, 32, 96, 40, $game_party.steps.to_s, 2)
  277.     bitmap = RPG::Cache.icon("020-Accessory05")
  278.     self.contents.blt(105, 40, bitmap, Rect.new(0, 0, 24, 24))
  279.   end
  280. end
  281. #==============================================================================
  282. # ** Window_MenuStatus
  283. #------------------------------------------------------------------------------
  284. #  This window displays party member status on the menu screen.
  285. #==============================================================================
  286.  
  287. class Window_MenuStatus < Window_Selectable
  288.  
  289.   def initialize
  290.     super(0, 0, 640, 287)
  291.     self.contents = Bitmap.new(width - 32, height - 32)
  292.     refresh
  293.     self.active = false
  294.     self.index = -1
  295.   end
  296.  
  297.   def refresh
  298.     self.contents.clear
  299.     @item_max = $game_party.actors.size
  300.     for i in 0...$game_party.actors.size
  301.       x = 64
  302.       y = 0
  303.       actor = $game_party.actors[0]
  304.       draw_actor_graphic(actor, x - 40, y + 80)
  305.       draw_actor_name(actor, x - 60, y)
  306.       draw_actor_class(actor, x + 110, y)
  307.       draw_actor_level(actor, x, y + 32)
  308.       draw_actor_state(actor, x + 110, y + 32)
  309.       draw_actor_exp(actor, x, y + 158)
  310.       draw_actor_barz(actor, x, y + 190, "horizontal", 168, 1, actor.now_exp.to_f, actor.next_exp, Color.new(-255, 200, -86, 255), Color.new(-168, -157, 184, 255))
  311.       draw_actor_health(actor, x, y + 74)
  312.       draw_actor_barz(actor, x, y + 106 , "horizontal", 168, 4, actor.hp, actor.maxhp, Color.new(102, --200, 160, 0), Color.new(0, 0, 0, 0))
  313.       draw_actor_mana(actor, x, y + 116)
  314.       draw_actor_barz(actor, x, y + 148, "horizontal", 168, 4, actor.sp, actor.maxsp, Color.new(0, 0, 0, 0), Color.new(-102, 160, -200, 0))
  315.       draw_actor_parameter(actor, x + 242, y - 8, 0)
  316.       draw_actor_parameter(actor, x + 242, y + 30, 1)
  317.       draw_actor_parameter(actor, x + 242, y + 68, 2)
  318.       draw_actor_parameter(actor, x + 242, y + 110, 3)
  319.       draw_actor_parameter(actor, x + 242, y + 152, 4)
  320.       draw_actor_parameter(actor, x + 242, y + 194, 5)
  321.       draw_actor_parameter(actor, x + 242, y + 232, 6)
  322.       draw_actor_barz(actor, x + 415, y + 10, "horizontal", 168, 1, actor.atk, 999, Color.new(242, 2, 6, 255), Color.new(253, 53, 56, 255))
  323.       draw_actor_barz(actor, x + 415, y + 47, "horizontal", 168, 1, actor.pdef, 999, Color.new(228, 253, 48, 255), Color.new(238, 254, 124, 255))
  324.       draw_actor_barz(actor, x + 415, y + 85, "horizontal", 168, 1, actor.mdef, 999, Color.new(229, 78, 253, 255), Color.new(237, 134, 254, 255))
  325.       draw_actor_barz(actor, x + 415, y + 125, "horizontal", 168, 1, actor.str, 999, Color.new(254, 209, 154, 255), Color.new(253, 163, 53, 255))
  326.       draw_actor_barz(actor, x + 415, y + 167, "horizontal", 168, 1, actor.dex, 999, Color.new(222, 222, 222, 255), Color.new(255, 255, 255, 255))
  327.       draw_actor_barz(actor, x + 415, y + 209, "horizontal", 168, 1, actor.agi, 999, Color.new(8, 160, 253, 255), Color.new(119, 203, 254, 255))
  328.       draw_actor_barz(actor, x + 415, y + 247, "horizontal", 168, 1, actor.int, 999, Color.new(33, 253, 86, 255), Color.new(124, 254, 155, 255))
  329.       draw_item_name($data_weapons[actor.weapon_id], x, y + 210)
  330.     end
  331.   end
  332.  
  333. #==============================================================================
  334. # ** Cursor_update
  335. #=============================================================================
  336.  
  337.   def update_cursor_rect
  338.     if @index < 0
  339.       self.cursor_rect.empty
  340.     else
  341.       self.cursor_rect.set(0, @index * 300, self.width - 32, 256)
  342.     end
  343.   end
  344. end
  345.  
  346. #==============================================================================
  347. # ** Scene_Menu
  348. #------------------------------------------------------------------------------
  349. #  This class performs menu screen processing.
  350. #==============================================================================
  351.  
  352. class Scene_Menu
  353.   #--------------------------------------------------------------------------
  354.   # * Object Initialization
  355.   #     menu_index : command cursor's initial position
  356.   #--------------------------------------------------------------------------
  357.   def initialize(menu_index = 0)
  358.     @menu_index = menu_index
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # * Main Processing
  362.   #--------------------------------------------------------------------------
  363.   def main
  364.     # Make command window
  365.     s1 = $data_system.words.item
  366.     s2 = $data_system.words.skill
  367.     s3 = $data_system.words.equip
  368.     s4 = "Quest Log"
  369.     s5 = "More..."
  370.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
  371.     @command_window.index = @menu_index
  372.     @command_window.width = 160
  373.     @command_window.back_opacity = 0
  374.     # Make MapName Window
  375.     @mapname_window = Window_Mapname.new
  376.     @mapname_window.x = 480
  377.     @mapname_window.y = 0
  378.     #Make Avatar Window
  379.     @avatar_window = Window_Avatar.new
  380.     # Make play time window
  381.     @playtime_window = Window_PlayTime.new
  382.     @playtime_window.x = 320
  383.     @playtime_window.y = 0
  384.     # Make steps window
  385.     @steps_window = Window_Steps.new
  386.     @steps_window.x = 320
  387.     @steps_window.y = 96
  388.     # Make gold window
  389.     @gold_window = Window_Gold.new
  390.     @gold_window.x = 480
  391.     @gold_window.y = 96
  392.     # Make status window
  393.     @status_window = Window_MenuStatus.new
  394.     @status_window.x = 0
  395.     @status_window.y = 192
  396.     # Execute transition
  397.     Graphics.transition
  398.     # Main loop
  399.     loop do
  400.       # Update game screen
  401.       Graphics.update
  402.       # Update input information
  403.       Input.update
  404.       # Frame update
  405.       update
  406.       # Abort loop if screen is changed
  407.       if $scene != self
  408.         break
  409.       end
  410.     end
  411.     # Prepare for transition
  412.     Graphics.freeze
  413.     # Dispose of windows
  414.     @avatar_window.dispose
  415.     @mapname_window.dispose
  416.     @command_window.dispose
  417.     @playtime_window.dispose
  418.     @steps_window.dispose
  419.     @gold_window.dispose
  420.     @status_window.dispose
  421.   end
  422.  
  423.   #--------------------------------------------------------------------------
  424.   # * Frame Update
  425.   #--------------------------------------------------------------------------
  426.   def update
  427.     # Update windows
  428.     @avatar_window.update
  429.     @mapname_window.update
  430.     @command_window.update
  431.     @playtime_window.update
  432.     @steps_window.update
  433.     @gold_window.update
  434.     @status_window.update
  435.     # If command window is active: call update_command
  436.     if @command_window.active
  437.       update_command
  438.       return
  439.     end
  440.     # If status window is active: call update_status
  441.     if @status_window.active
  442.       update_status
  443.       return
  444.     end
  445.   end
  446.   #--------------------------------------------------------------------------
  447.   # * Frame Update (when command window is active)
  448.   #--------------------------------------------------------------------------
  449.   def update_command
  450.     # If B button was pressed
  451.     if Input.trigger?(Input::B)
  452.       # Play cancel SE
  453.       $game_system.se_play($data_system.cancel_se)
  454.       # Switch to map screen
  455.       $scene = Scene_Map.new
  456.       return
  457.     end
  458.     # If C button was pressed
  459.     if Input.trigger?(Input::C)
  460.       # If command other than save or end game, and party members = 0
  461.       if $game_party.actors.size == 0 and @command_window.index < 1
  462.         # Play buzzer SE
  463.         $game_system.se_play($data_system.buzzer_se)
  464.         return
  465.       end
  466.       # Branch by command window cursor position
  467.       case @command_window.index
  468.  
  469.       when 0  # Item
  470.         $game_system.se_play($data_system.decision_se)
  471.         $scene = Scene_Item.new
  472.       when 1  #Skill
  473.         $game_system.se_play($data_system.decision_se)
  474.         $scene = Scene_Skill.new(@status_window.index)
  475.       when 2  # Equip
  476.         $game_system.se_play($data_system.decision_se)
  477.         $scene = Scene_Equip.new(@status_window.index)
  478.       when 3  # Quest Log
  479.         $game_system.se_play($data_system.decision_se)
  480.         $scene = Scene_Quest.new
  481.       when 4  # Options
  482.         # Play decision SE
  483.         $game_system.se_play($data_system.decision_se)
  484.         # Switch to end game screen
  485.         $scene = Scene_End.new
  486.       end
  487.       return
  488.     end
  489.   end
  490. end
  491.  
  492. #==============================================================================
  493. # ** Window_Item
  494. #------------------------------------------------------------------------------
  495. #  This window displays items in possession on the item and battle screens.
  496. #==============================================================================
  497.  
  498. class Window_Item < Window_Selectable
  499.   #--------------------------------------------------------------------------
  500.   # * Object Initialization
  501.   #     actor : actor
  502.   #--------------------------------------------------------------------------
  503.   def initialize(actor = nil)
  504.     super(0, 128, 640, 352)
  505.     @actor = actor.nil? ? $game_party.actors[0] : actor
  506.     @column_max = 2
  507.     refresh
  508.     self.index = 0
  509.     # If in battle, move window to center of screen
  510.     # and make it semi-transparent
  511.     if $game_temp.in_battle
  512.       self.y = 64
  513.       self.height = 256
  514.       self.back_opacity = 160
  515.     end
  516.   end
  517. end
  518.  
  519. #==============================================================================
  520. # ** Scene_Item
  521. #------------------------------------------------------------------------------
  522. #  This class performs item screen processing.
  523. #==============================================================================
  524.  
  525. class Scene_Item
  526.  
  527.   #--------------------------------------------------------------------------
  528.   # * Object Initialization
  529.   #     actor_index : actor index
  530.   #--------------------------------------------------------------------------
  531.   def initialize(actor_index = 0, equip_index = 0)
  532.     @actor_index = actor_index
  533.   end
  534.   #--------------------------------------------------------------------------
  535.   # * Main Processing
  536.   #--------------------------------------------------------------------------
  537.   def main
  538.     # Get actor
  539.     @actor = $game_party.actors[@actor_index]
  540.     # Make help window, status window, and skill window
  541.     @help_window = Window_Help.new
  542.     @status_window = Window_SkillStatus.new(@actor)
  543.     @item_window = Window_Item.new(2)
  544.     # Associate help window
  545.     @item_window.help_window = @help_window
  546.     # Make target window (set to invisible / inactive)
  547.     @target_window = Window_Target.new
  548.     @target_window.visible = false
  549.     @target_window.active = false
  550.     # Execute transition
  551.     Graphics.transition
  552.     # Main loop
  553.     loop do
  554.       # Update game screen
  555.       Graphics.update
  556.       # Update input information
  557.       Input.update
  558.       # Frame update
  559.       update
  560.       # Abort loop if screen is changed
  561.       if $scene != self
  562.         break
  563.       end
  564.     end
  565.     # Prepare for transition
  566.     Graphics.freeze
  567.     # Dispose of windows
  568.     @help_window.dispose
  569.     @status_window.dispose
  570.     @item_window.dispose
  571.     @target_window.dispose
  572.   end
  573.   #--------------------------------------------------------------------------
  574.   # * Frame Update
  575.   #--------------------------------------------------------------------------
  576.   def update
  577.     # Update windows
  578.     @help_window.update
  579.     @status_window.update
  580.     @item_window.update
  581.     @target_window.update
  582.     # If item window is active: call update_item
  583.     if @item_window.active
  584.       update_item
  585.       return
  586.     end
  587.     # If target window is active: call update_target
  588.     if @target_window.active
  589.       update_target
  590.       return
  591.     end
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # * Frame Update (when item window is active)
  595.   #--------------------------------------------------------------------------  
  596.   def update_item
  597.     # If B button was pressed
  598.     if Input.trigger?(Input::B)
  599.       # Play cancel SE
  600.       $game_system.se_play($data_system.cancel_se)
  601.       # Switch to menu screen
  602.       $scene = Scene_Menu.new(0)
  603.       return
  604.     end
  605.     # If C button was pressed
  606.     if Input.trigger?(Input::C)
  607.       # Get currently selected data on the item window
  608.       @item = @item_window.item
  609.       # If not a use item
  610.       unless @item.is_a?(RPG::Item)
  611.         # Play buzzer SE
  612.         $game_system.se_play($data_system.buzzer_se)
  613.         return
  614.       end
  615.       # If it can't be used
  616.       unless $game_party.item_can_use?(@item.id)
  617.         # Play buzzer SE
  618.         $game_system.se_play($data_system.buzzer_se)
  619.         return
  620.       end
  621.       # Play decision SE
  622.       $game_system.se_play($data_system.decision_se)
  623.       # If effect scope is an ally
  624.       if @item.scope >= 3
  625.       # If items are used up
  626.       if $game_party.item_number(@item.id) == 0
  627.         # Play buzzer SE
  628.         $game_system.se_play($data_system.buzzer_se)
  629.         return
  630.       end
  631.       # If target is all
  632.       if @target_window.index == -1
  633.         # Apply item effects to entire party
  634.         used = false
  635.         for i in $game_party.actors
  636.           used |= i.item_effect(@item)
  637.         end
  638.       end
  639.       # If single target
  640.       if @target_window.index >= 0
  641.         # Apply item use effects to target actor
  642.         target = $game_party.actors[@target_window.index]
  643.         used = target.item_effect(@item)
  644.       end
  645.       # If an item was used
  646.       if used
  647.         # Play item use SE
  648.         $game_system.se_play(@item.menu_se)
  649.         # If consumable
  650.         if @item.consumable
  651.           # Decrease used items by 1
  652.           $game_party.lose_item(@item.id, 1)
  653.           # Redraw item window item
  654.           @item_window.draw_item(@item_window.index)
  655.         end
  656.         # Remake target window contents
  657.         @target_window.refresh
  658.         @status_window.refresh
  659.         # If all party members are dead
  660.         if $game_party.all_dead?
  661.           # Switch to game over screen
  662.           $scene = Scene_Gameover.new
  663.           return
  664.         end
  665.         # If common event ID is valid
  666.         if @item.common_event_id > 0
  667.           # Common event call reservation
  668.           $game_temp.common_event_id = @item.common_event_id
  669.           # Switch to map screen
  670.           $scene = Scene_Map.new
  671.           return
  672.         end
  673.       end
  674.       # If effect scope is other than an ally
  675.       else
  676.         # If command event ID is valid
  677.         if @item.common_event_id > 0
  678.           # Command event call reservation
  679.           $game_temp.common_event_id = @item.common_event_id
  680.           # Play item use SE
  681.           $game_system.se_play(@item.menu_se)
  682.           # If consumable
  683.           if @item.consumable
  684.             # Decrease used items by 1
  685.             $game_party.lose_item(@item.id, 1)
  686.             # Draw item window item
  687.             @item_window.draw_item(@item_window.index)
  688.           end
  689.           # Switch to map screen
  690.           $scene = Scene_Map.new
  691.           return
  692.         end
  693.       end
  694.       return
  695.     end
  696.   end
  697. end
  698.  
  699. #==============================================================================
  700. # ** Scene_Skill
  701. #------------------------------------------------------------------------------
  702. #  This class performs skill screen processing.
  703. #==============================================================================
  704.  
  705. class Scene_Skill
  706.  
  707.   def update_skill
  708.     # If B button was pressed
  709.     if Input.trigger?(Input::B)
  710.       # Play cancel SE
  711.       $game_system.se_play($data_system.cancel_se)
  712.       # Switch to menu screen
  713.       $scene = Scene_Menu.new(1)
  714.       return
  715.     end
  716.     # If C button was pressed
  717.     if Input.trigger?(Input::C)
  718.       # Get currently selected data on the skill window
  719.       @skill = @skill_window.skill
  720.       # If unable to use
  721.       if @skill == nil or not @actor.skill_can_use?(@skill.id)
  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.       # If effect scope is ally
  729.       if @skill.scope >= 3
  730.       # If unable to use because SP ran out
  731.       unless @actor.skill_can_use?(@skill.id)
  732.         # Play buzzer SE
  733.         $game_system.se_play($data_system.buzzer_se)
  734.         return
  735.       end
  736.       # If target is all
  737.       if @target_window.index == -1
  738.         # Apply skill use effects to entire party
  739.         used = false
  740.         for i in $game_party.actors
  741.           used |= i.skill_effect(@actor, @skill)
  742.         end
  743.       end
  744.       # If target is user
  745.       if @target_window.index <= -2
  746.         # Apply skill use effects to target actor
  747.         target = $game_party.actors[@target_window.index + 10]
  748.         used = target.skill_effect(@actor, @skill)
  749.       end
  750.       # If single target
  751.       if @target_window.index >= 0
  752.         # Apply skill use effects to target actor
  753.         target = $game_party.actors[@target_window.index]
  754.         used = target.skill_effect(@actor, @skill)
  755.       end
  756.       # If skill was used
  757.       if used
  758.         # Play skill use SE
  759.         $game_system.se_play(@skill.menu_se)
  760.         # Use up SP
  761.         @actor.sp -= @skill.sp_cost
  762.         # Remake each window content
  763.         @status_window.refresh
  764.         @skill_window.refresh
  765.         @target_window.refresh
  766.         # If entire party is dead
  767.         if $game_party.all_dead?
  768.           # Switch to game over screen
  769.           $scene = Scene_Gameover.new
  770.           return
  771.         end
  772.         # If command event ID is valid
  773.         if @skill.common_event_id > 0
  774.           # Command event call reservation
  775.           $game_temp.common_event_id = @skill.common_event_id
  776.           # Switch to map screen
  777.           $scene = Scene_Map.new
  778.           return
  779.         end
  780.       end
  781.       # If effect scope is other than ally
  782.       else
  783.         # If common event ID is valid
  784.         if @skill.common_event_id > 0
  785.           # Common event call reservation
  786.           $game_temp.common_event_id = @skill.common_event_id
  787.           # Play use skill SE
  788.           $game_system.se_play(@skill.menu_se)
  789.           # Use up SP
  790.           @actor.sp -= @skill.sp_cost
  791.           # Remake each window content
  792.           @status_window.refresh
  793.           @skill_window.refresh
  794.           @target_window.refresh
  795.           # Switch to map screen
  796.           $scene = Scene_Map.new
  797.           return
  798.         end
  799.       end
  800.       return
  801.     end
  802.     # If R button was pressed
  803.     if Input.trigger?(Input::R)
  804.       # Play cursor SE
  805.       $game_system.se_play($data_system.cursor_se)
  806.       # To next actor
  807.       @actor_index += 1
  808.       @actor_index %= $game_party.actors.size
  809.       # Switch to different skill screen
  810.       $scene = Scene_Skill.new(@actor_index)
  811.       return
  812.     end
  813.     # If L button was pressed
  814.     if Input.trigger?(Input::L)
  815.       # Play cursor SE
  816.       $game_system.se_play($data_system.cursor_se)
  817.       # To previous actor
  818.       @actor_index += $game_party.actors.size - 1
  819.       @actor_index %= $game_party.actors.size
  820.       # Switch to different skill screen
  821.       $scene = Scene_Skill.new(@actor_index)
  822.       return
  823.     end
  824.   end
  825. end
  826.  
  827. #==============================================================================
  828. # ** Scene_Equip
  829. #------------------------------------------------------------------------------
  830. #  This class performs equipment screen processing.
  831. #==============================================================================
  832.  
  833. class Scene_Equip
  834.  
  835.   def update_right
  836.     # If B button was pressed
  837.     if Input.trigger?(Input::B)
  838.       # Play cancel SE
  839.       $game_system.se_play($data_system.cancel_se)
  840.       # Switch to menu screen
  841.       $scene = Scene_Menu.new(2)
  842.       return
  843.     end
  844.     # If C button was pressed
  845.     if Input.trigger?(Input::C)
  846.       # If equipment is fixed
  847.       if @actor.equip_fix?(@right_window.index)
  848.         # Play buzzer SE
  849.         $game_system.se_play($data_system.buzzer_se)
  850.         return
  851.       end
  852.       # Play decision SE
  853.       $game_system.se_play($data_system.decision_se)
  854.       # Activate item window
  855.       @right_window.active = false
  856.       @item_window.active = true
  857.       @item_window.index = 0
  858.       return
  859.     end
  860.     # If R button was pressed
  861.     if Input.trigger?(Input::R)
  862.       # Play cursor SE
  863.       $game_system.se_play($data_system.cursor_se)
  864.       # To next actor
  865.       @actor_index += 1
  866.       @actor_index %= $game_party.actors.size
  867.       # Switch to different equipment screen
  868.       $scene = Scene_Equip.new(@actor_index, @right_window.index)
  869.       return
  870.     end
  871.     # If L button was pressed
  872.     if Input.trigger?(Input::L)
  873.       # Play cursor SE
  874.       $game_system.se_play($data_system.cursor_se)
  875.       # To previous actor
  876.       @actor_index += $game_party.actors.size - 1
  877.       @actor_index %= $game_party.actors.size
  878.       # Switch to different equipment screen
  879.       $scene = Scene_Equip.new(@actor_index, @right_window.index)
  880.       return
  881.     end
  882.   end
  883. end
  884.  
  885. #==============================================================================
  886. # ** Scene_Save
  887. #------------------------------------------------------------------------------
  888. #  This class performs save screen processing.
  889. #==============================================================================
  890.  
  891. class Scene_Save < Scene_File
  892.  
  893.   def on_decision(filename)
  894.     # Play save SE
  895.     $game_system.se_play($data_system.save_se)
  896.     # Write save data
  897.     file = File.open(filename, "wb")
  898.     write_save_data(file)
  899.     file.close
  900.     # If called from event
  901.     if $game_temp.save_calling
  902.       # Clear save call flag
  903.       $game_temp.save_calling = false
  904.       # Switch to map screen
  905.       $scene = Scene_Map.new
  906.       return
  907.     end
  908.     # Switch to menu screen
  909.     $scene = Scene_Menu.new(0)
  910.   end
  911.  
  912.   def on_cancel
  913.     # Play cancel SE
  914.     $game_system.se_play($data_system.cancel_se)
  915.     # If called from event
  916.     if $game_temp.save_calling
  917.       # Clear save call flag
  918.       $game_temp.save_calling = false
  919.       # Switch to map screen
  920.       $scene = Scene_Map.new
  921.       return
  922.     end
  923.     # Switch to menu screen
  924.     $scene = Scene_Menu.new(0)
  925.   end
  926. end
  927.  
  928. class Scene_End
  929.   #--------------------------------------------------------------------------
  930.   # * Main Processing
  931.   #--------------------------------------------------------------------------
  932.   def main
  933.     # Make command window
  934.     s1 = "Save"
  935.     s2 = "To Title"
  936.     s3 = "Exit"
  937.     s4 = "Cancel"
  938.     @command_window = Window_Command.new(192, [s1, s2, s3, s4])
  939.     @command_window.x = 320 - @command_window.width / 2
  940.     @command_window.y = 240 - @command_window.height / 2
  941.     # Execute transition
  942.     Graphics.transition
  943.     if $game_system.save_disabled
  944.      # Disable save
  945.      @command_window.disable_item(0)
  946.     end
  947.     # Main loop
  948.     loop do
  949.       # Update game screen
  950.       Graphics.update
  951.       # Update input information
  952.       Input.update
  953.       # Frame Update
  954.       update
  955.       # Abort loop if screen is changed
  956.       if $scene != self
  957.         break
  958.       end
  959.     end
  960.     # Prepare for transition
  961.     Graphics.freeze
  962.     # Dispose of window
  963.     @command_window.dispose
  964.     # If switching to title screen
  965.     if $scene.is_a?(Scene_Title)
  966.       # Fade out screen
  967.       Graphics.transition
  968.       Graphics.freeze
  969.     end
  970.   end
  971.   #--------------------------------------------------------------------------
  972.   # * Frame Update
  973.   #--------------------------------------------------------------------------
  974.   def update
  975.     # Update command window
  976.     @command_window.update
  977.     # If B button was pressed
  978.     if Input.trigger?(Input::B)
  979.       # Play cancel SE
  980.       $game_system.se_play($data_system.cancel_se)
  981.       # Switch to menu screen
  982.       $scene = Scene_Menu.new(4)
  983.       return
  984.     end
  985.     # If C button was pressed
  986.     if Input.trigger?(Input::C)
  987.       # Branch by command window cursor position
  988.       case @command_window.index
  989.       when 0  # Save
  990.         command_save
  991.       when 1  # to title
  992.         command_to_title
  993.       when 2  # shutdown
  994.         command_shutdown
  995.       when 3  # cancel
  996.         command_cancel
  997.       end
  998.       return
  999.     end
  1000.   end
  1001.   #--------------------------------------------------------------------------
  1002.   # * Process When Choosing [Save] Command
  1003.   #--------------------------------------------------------------------------
  1004.   def command_save
  1005.     if $game_system.save_disabled
  1006.         $game_system.se_play($data_system.buzzer_se)
  1007.       return
  1008.     end
  1009.     $game_system.se_play($data_system.decision_se)
  1010.     $scene = Scene_Save.new
  1011.   end
  1012.   #--------------------------------------------------------------------------
  1013.   # * Process When Choosing [To Title] Command
  1014.   #--------------------------------------------------------------------------
  1015.   def command_to_title
  1016.     # Play decision SE
  1017.     $game_system.se_play($data_system.decision_se)
  1018.     # Fade out BGM, BGS, and ME
  1019.     Audio.bgm_fade(800)
  1020.     Audio.bgs_fade(800)
  1021.     Audio.me_fade(800)
  1022.     # Switch to title screen
  1023.     $scene = Scene_Title.new
  1024.   end
  1025.   #--------------------------------------------------------------------------
  1026.   # * Process When Choosing [Shutdown] Command
  1027.   #--------------------------------------------------------------------------
  1028.   def command_shutdown
  1029.     # Play decision SE
  1030.     $game_system.se_play($data_system.decision_se)
  1031.     # Fade out BGM, BGS, and ME
  1032.     Audio.bgm_fade(800)
  1033.     Audio.bgs_fade(800)
  1034.     Audio.me_fade(800)
  1035.     # Shutdown
  1036.     $scene = nil
  1037.   end
  1038.   #--------------------------------------------------------------------------
  1039.   # *  Process When Choosing [Cancel] Command
  1040.   #--------------------------------------------------------------------------
  1041.   def command_cancel
  1042.     # Play decision SE
  1043.     $game_system.se_play($data_system.decision_se)
  1044.     # Switch to menu screen
  1045.     $scene = Scene_Menu.new(4)
  1046.   end
  1047. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement