Advertisement
Guest User

Expanded Actor Menu

a guest
Nov 20th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 16.32 KB | None | 0 0
  1. # )--------------------------------------------------(
  2. # )--     Author:     Mr Trivel                    --(
  3. # )--     Name:       Expanded Actor Menu          --(
  4. # )--     Created:    2014-06-06                   --(
  5. # )--     Version:    1.12a                        --(
  6. # )--------------------------------------------------(
  7. # )--     Requires:   None                         --(
  8. # )--------------------------------------------------(
  9. # )--             Description                      --(
  10. # )--  Sets up status window so it displays only   --(
  11. # )--  a single actor data. Browse through other   --(
  12. # )--  actors by using LEFT and RIGHT buttons.     --(
  13. # )--------------------------------------------------(
  14. # )--             Instructions                     --(
  15. # )--             Plug & Play                      --(
  16. # )--------------------------------------------------(
  17. # )--             LICENSE INFO                     --(
  18. # )--http://mrtrivelvx.wordpress.com/terms-of-use/ --(
  19. # )--------------------------------------------------(
  20.  
  21. module MrTS
  22.   module Vocab
  23.    
  24.     # )--------------------------------------------------(
  25.     # )--  Ex-parameter names, feel free to customize  --(
  26.     # )--  Ex-params of index 3, 7, 8 & 9 are not drawn--(
  27.     # )--------------------------------------------------(
  28.     XPARAMS = [ "Hit",
  29.                 "Evasion",
  30.                 "Critical",
  31.                 "CEV", #not drawn by default
  32.                 "Mag Evasion",
  33.                 "Mag Reflect",
  34.                 "Counter",
  35.                 "HRG", #not drawn by default
  36.                 "MRG", #not drawn by default
  37.                 "TRG" ]#not drawn by default
  38.   end
  39.   module Data
  40.     # )---------------------------------------------(
  41.     # )--  Ex-parameter indexes that are ignored  --(
  42.     # )---------------------------------------------(
  43.     # )--  WARNING: If you have less than 4, it   --(
  44.     # )--  will draw them over equipment.         --(
  45.     # )---------------------------------------------(
  46.     IGNORE = [3, 7, 8, 9]
  47.   end
  48. end
  49.  
  50. $imported = {} if $imported.nil?
  51. $imported["MrTS_Expanded_Actor_Menu"] = true
  52.  
  53.  
  54. #)-------------------------(
  55. #)--  Class: Scene_Menu  --(
  56. #)-------------------------(
  57. class Scene_Menu < Scene_MenuBase
  58.  
  59.   # )--------------------------------(
  60.   # )--  Overwrite Method: update  --(
  61.   # )--------------------------------(
  62.   def update
  63.     super
  64.    
  65.     if Input.trigger?(:RIGHT)
  66.      
  67.       if !@in_item_menu
  68.         next_actor
  69.         set_actor_all_a
  70.       end
  71.      
  72.     elsif Input.trigger?(:LEFT)
  73.      
  74.       if !@in_item_menu
  75.         prev_actor
  76.         set_actor_all_a
  77.       end
  78.      
  79.     end
  80.   end
  81.  
  82.   def create_help_window
  83.     @help_window = Window_Help.new
  84.     @help_window.viewport = @viewport
  85.     @help_window.openness = 0
  86.   end
  87.  
  88.   # )-----------------------------------(
  89.   # )--  New Method: set_actor_all_a  --(
  90.   # )-----------------------------------(  
  91.   def set_actor_all_a
  92.     @equipment_window.actor = $game_party.menu_actor
  93.     @status_window.actor = $game_party.menu_actor
  94.     @item_list_window.actor = $game_party.menu_actor
  95.   end
  96.  
  97.   # )---------------------------------------(
  98.   # )--  Alias To: create_command_window  --(
  99.   # )---------------------------------------(
  100.   alias mrts_sm_start start
  101.   def start
  102.     mrts_sm_start
  103.     create_help_window
  104.     create_equipment_window
  105.     create_item_list_window
  106.     @in_item_menu = false
  107.     set_actor_all_a
  108.   end
  109.  
  110.   # )-------------------------------------------(
  111.   # )--  New Method: create_item_list_window  --(
  112.   # )-------------------------------------------(
  113.   def create_item_list_window
  114.     @item_list_window = MrTS_Status_Item_List.new(@command_window.width)
  115.     @item_list_window.openness = 0
  116.     @item_list_window.status_window = @status_window
  117.     @item_list_window.help_window = @help_window
  118.     @item_list_window.set_handler(:ok,       method(:ok_item))
  119.     @item_list_window.set_handler(:cancel,   method(:back_item))
  120.   end
  121.  
  122.   # )---------------------------(
  123.   # )--  New Method: ok_item  --(
  124.   # )---------------------------(
  125.   def ok_item
  126.     Sound.play_equip
  127.     @actor.change_equip(@equipment_window.index, @item_list_window.item)
  128.     @equipment_window.activate
  129.     @equipment_window.refresh
  130.     @item_list_window.close
  131.     @item_list_window.unselect
  132.     @help_window.close
  133.     @status_window.refresh
  134.     @status_window.set_temp_actor(nil)
  135.     @in_item_menu = false
  136.   end
  137.  
  138.   # )-----------------------------(
  139.   # )--  New Method: back_item  --(
  140.   # )-----------------------------(
  141.   def back_item
  142.     @equipment_window.activate
  143.     @item_list_window.close
  144.     @help_window.close
  145.     @in_item_menu = false
  146.   end
  147.  
  148.   # )-------------------------------------------(
  149.   # )--  New Method: create_equipment_window  --(
  150.   # )-------------------------------------------(
  151.   def create_equipment_window
  152.     @equipment_window = MrTS_Equipment_Window.new(@command_window.width)
  153.     @equipment_window.status_window = @status_window
  154.     @equipment_window.opacity = 0
  155.     @equipment_window.set_handler(:ok,        method(:ok_equip))
  156.     @equipment_window.set_handler(:cancel,    method(:back_equip))
  157.   end
  158.  
  159.   # )----------------------------(
  160.   # )--  New Method: ok_equip  --(
  161.   # )----------------------------(
  162.   def ok_equip
  163.     index = @equipment_window.index
  164.     if @actor.equip_change_ok?(index)
  165.       @item_list_window.slot_id = index
  166.       @item_list_window.refresh
  167.       @item_list_window.open
  168.       @item_list_window.activate
  169.       @item_list_window.select(0)
  170.       @help_window.open
  171.       @in_item_menu = true
  172.     else
  173.       Sound.play_buzzer
  174.       @equipment_window.activate
  175.     end
  176.   end
  177.  
  178.   # )------------------------------(
  179.   # )--  New Method: back_equip  --(
  180.   # )------------------------------(
  181.   def back_equip
  182.     @command_window.activate
  183.     @equipment_window.unselect
  184.   end
  185.  
  186.   # )-----------------------------------------------(
  187.   # )--  Overwrite Method: create_command_window  --(
  188.   # )-----------------------------------------------(
  189.   def create_command_window
  190.     @command_window = Window_MenuCommand.new
  191.     @command_window.set_handler(:item,      method(:command_item))
  192.     @command_window.set_handler(:skill,     method(:command_skill))
  193.     @command_window.set_handler(:equip,     method(:command_equip))
  194.     @command_window.set_handler(:save,      method(:command_save))
  195.     @command_window.set_handler(:game_end,  method(:command_game_end))
  196.     @command_window.set_handler(:cancel,    method(:return_scene))
  197.   end
  198.  
  199.   # )---------------------------------(
  200.   # )--  New Method: command_skill  --(
  201.   # )---------------------------------(
  202.   def command_skill
  203.     SceneManager.call(Scene_Skill)
  204.   end
  205.  
  206.   # )---------------------------------(
  207.   # )--  New Method: command_equip  --(
  208.   # )---------------------------------(
  209.   def command_equip
  210.     @equipment_window.activate
  211.     @equipment_window.select(0)
  212.   end
  213.  
  214.   # )----------------------------------------------(
  215.   # )--  Overwrite Method: create_status_window  --(
  216.   # )----------------------------------------------(
  217.   def create_status_window
  218.     @status_window = MrTS_Window_Solo_Status.new(@command_window.width, 0)
  219.   end
  220. end
  221.  
  222.  
  223. #)------------------------------------(
  224. #)--  Class: MrTS_Status_Item_List  --(
  225. #)------------------------------------(
  226. class MrTS_Status_Item_List < Window_EquipItem
  227.  
  228.   attr_reader :status_window
  229.  
  230.   # )--------------------------(
  231.   # )--  Method: initialize  --(
  232.   # )--------------------------(
  233.   def initialize(width)
  234.     super(width, 104 + line_height * 9, Graphics.width-width, fitting_height(3))
  235.     @actor = $game_party.leader
  236.     @slot_id = 0
  237.     @status_window = status_window
  238.     refresh
  239.   end
  240.  
  241.   # )------------------------------(
  242.   # )--  Method: status_window=  --(
  243.   # )------------------------------(
  244.   def status_window=(status_window)
  245.     @status_window = status_window
  246.   end
  247.  
  248.   def help_window=(help_window)
  249.     @help_window = help_window
  250.     @help_window.width = self.width
  251.     @help_window.x = self.x
  252.     @help_window.y = self.y - fitting_height(2)
  253.     @help_window.create_contents
  254.   end
  255.  
  256.   # )-----------------------(
  257.   # )--  Method: col_max  --(
  258.   # )-----------------------(
  259.   def col_max
  260.     return 1
  261.   end
  262.  
  263.   # )--------------------------------(
  264.   # )--  Method: call_update_help  --(
  265.   # )--------------------------------(
  266.   def call_update_help
  267.     update_help
  268.   end
  269.  
  270.   # )---------------------------(
  271.   # )--  Method: update_help  --(
  272.   # )---------------------------(
  273.   def update_help
  274.     @help_window.set_item(item) if @help_window
  275.  
  276.     if @actor && @status_window
  277.       temp_actor = Marshal.load(Marshal.dump(@actor))
  278.       temp_actor.force_change_equip(@slot_id, item)
  279.       status_window.set_temp_actor(temp_actor)
  280.     end
  281.   end
  282.  
  283.  
  284. end
  285.  
  286.  
  287. #)------------------------------------(
  288. #)--  Class: MrTS_Equipment_Window  --(
  289. #)------------------------------------(
  290. class MrTS_Equipment_Window < Window_EquipSlot
  291.  
  292.   attr_reader :status_window
  293.  
  294.   # )------------------------------------(
  295.   # )--  Overwrite Method: initialize  --(
  296.   # )------------------------------------(
  297.   def initialize(x)
  298.     super(x, 96 + line_height * 7, Graphics.width-160)
  299.     @actor = $game_party.leader
  300.     create_contents
  301.     refresh
  302.   end
  303.  
  304.   # )------------------------------------------(
  305.   # )--  Overwrite Method: call_update_help  --(
  306.   # )------------------------------------------(
  307.   def call_update_help
  308.     update_help
  309.   end
  310.  
  311.   # )-------------------------------------(
  312.   # )--  Overwrite Method: update_help  --(
  313.   # )-------------------------------------(
  314.   def update_help
  315.     status_window.set_temp_actor(nil) if @status_window
  316.   end
  317. end
  318.  
  319.  
  320. #)--------------------------------------(
  321. #)--  Class: MrTS_Window_Solo_Status  --(
  322. #)--------------------------------------(
  323. class MrTS_Window_Solo_Status < Window_Base
  324.  
  325.   # )--------------------------(
  326.   # )--  Method: initialize  --(
  327.   # )--------------------------(
  328.   def initialize(x, y)
  329.     super(x, y, window_width, window_height)
  330.     @pending_index = -1
  331.     @temp_actor = nil
  332.     @actor = $game_party.leader
  333.     refresh
  334.   end
  335.  
  336.   # )----------------------------(
  337.   # )--  Method: window_width  --(
  338.   # )----------------------------(
  339.   def window_width
  340.     Graphics.width - 160
  341.   end
  342.  
  343.   # )-----------------------------(
  344.   # )--  Method: window_height  --(
  345.   # )-----------------------------(
  346.   def window_height
  347.     Graphics.height
  348.   end
  349.  
  350.   # )--------------------------------(
  351.   # )--  Method: draw_actor_param  --(
  352.   # )--------------------------------(
  353.   def draw_actor_param(actor, x, y, param_id, color = normal_color)
  354.     change_color(system_color)
  355.     draw_text(x, y, 120, line_height, Vocab::param(param_id))
  356.     change_color(color)
  357.     draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2)
  358.     change_color(normal_color)
  359.   end
  360.  
  361.   # )-----------------------------(
  362.   # )--  Method: draw_actor_hp  --(
  363.   # )-----------------------------(
  364.   def draw_actor_hp(actor, x, y, width = 124, color = normal_color)
  365.     draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  366.     change_color(system_color)
  367.     draw_text(x, y, 30, line_height, Vocab::hp_a)
  368.     draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
  369.       hp_color(actor), color)
  370.     end
  371.    
  372.   # )-----------------------------(
  373.   # )--  Method: draw_actor_mp  --(
  374.   # )-----------------------------(
  375.   def draw_actor_mp(actor, x, y, width = 124, color = normal_color)
  376.     draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
  377.     change_color(system_color)
  378.     draw_text(x, y, 30, line_height, Vocab::mp_a)
  379.     draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
  380.       mp_color(actor), color)
  381.   end
  382.  
  383.   # )-----------------------(
  384.   # )--  Method: refresh  --(
  385.   # )-----------------------(
  386.   def refresh
  387.     contents.clear
  388.     create_contents
  389.    
  390.     temp_color = normal_color
  391.    
  392.     draw_actor_face(@actor, 0, 0)
  393.     draw_actor_level(@actor, 96, 0)
  394.     draw_actor_name(@actor, 96, line_height)
  395.     draw_actor_class(@actor, 96, line_height*2)
  396.     if !$imported["MrTS_Thirst"]
  397.       draw_actor_xp(@actor, contents.width-160, line_height*2, 160)
  398.     elsif $imported["MrTS_Thirst"]
  399.       draw_thirst_gauge(@actor, contents.width-160, line_height*2, 160)
  400.     end    
  401.    
  402.     if @temp_actor == nil
  403.       draw_actor_hp(@actor, contents.width-160, 0, 160)
  404.       draw_actor_mp(@actor, contents.width-160, line_height, 160)
  405.     else
  406.       temp_color = param_change_color(@temp_actor.param(0)-@actor.param(0))
  407.       draw_actor_hp(@temp_actor, contents.width-160, 0, 160, temp_color)
  408.      
  409.       temp_color = param_change_color(@temp_actor.param(1)-@actor.param(1))
  410.       draw_actor_mp(@temp_actor, contents.width-160, line_height, 160, temp_color)
  411.     end
  412.    
  413.     #params
  414.     6.times do |i|
  415.       contents.gradient_fill_rect(-3, 96+line_height*i, 159, line_height-10, text_color(15), text_color(19))
  416.       dy = 96 + line_height * i
  417.      
  418.       if @temp_actor == nil
  419.         draw_actor_param(@actor, 0, dy, i + 2)
  420.       else
  421.         temp_color = param_change_color(@temp_actor.param(i+2)-@actor.param(i+2))
  422.         draw_actor_param(@temp_actor, 0, 96 + line_height * (i), i+2, temp_color)
  423.       end
  424.     end
  425.    
  426.     #xparams
  427.     skipped = 0
  428.     ignore = MrTS::Data::IGNORE #ignore these xparams
  429.     10.times do |i|
  430.       if !ignore.include?(i)
  431.         if @temp_actor == nil
  432.           draw_actor_xparam(@actor, contents.width-156, 96 + line_height * (i - skipped), i)
  433.         else
  434.           temp_color = param_change_color(@temp_actor.xparam(i)-@actor.xparam(i))
  435.           draw_actor_xparam(@temp_actor, contents.width-156, 96 + line_height * (i - skipped), i, temp_color)
  436.         end
  437.        
  438.       else
  439.         skipped += 1
  440.       end
  441.     end
  442.   end # of refresh
  443.  
  444.   # )---------------------------------(
  445.   # )--  Method: draw_actor_xparam  --(
  446.   # )---------------------------------(
  447.   def draw_actor_xparam(actor, x, y, param_id, color = normal_color)
  448.     contents.gradient_fill_rect(x-3, y, 159, line_height-10, text_color(15), text_color(19))
  449.     change_color(system_color)
  450.     draw_text(x, y, 120, line_height, MrTS::Vocab::XPARAMS[param_id])
  451.     change_color(color)
  452.     draw_text(x + 120 - 36, y, 72, line_height, (actor.xparam(param_id)*100).to_i.to_s + "%", 2)
  453.   end
  454.  
  455.   # )-----------------------------(
  456.   # )--  Method: draw_actor_xp  --(
  457.   # )-----------------------------(
  458.   def draw_actor_xp(actor, x, y, width = 124)
  459.     float = 1.0 * (actor.exp - actor.current_level_exp) / (actor.next_level_exp - actor.current_level_exp)
  460.     draw_gauge(x, y, width, float, text_color(28), text_color(29))
  461.     change_color(system_color)
  462.     draw_text(x, y, 30, line_height, "EXP")
  463.     change_color(normal_color)
  464.     draw_text(x + width - 140, y, (140-12)/2, line_height, actor.exp - actor.current_level_exp, 2)
  465.     draw_text(x+ width - 140/2, y, 12, line_height, "/", 2)
  466.     draw_text(x+ width - (140-12)/2, y, (140-12)/2, line_height, actor.next_level_exp - actor.current_level_exp, 2)
  467.   end
  468.  
  469.   # )------------------------------(
  470.   # )--  Method: set_temp_actor  --(
  471.   # )------------------------------(
  472.   def set_temp_actor(temp_actor)
  473.     return if @temp_actor == temp_actor
  474.     @temp_actor = temp_actor
  475.     refresh
  476.   end
  477.  
  478.   # )----------------------(
  479.   # )--  Method: actor=  --(
  480.   # )----------------------(
  481.   def actor=(actor)
  482.     return if @actor == actor
  483.     @actor = actor
  484.     refresh
  485.   end
  486.  
  487. end
  488.  
  489.  
  490. # )---------------------------------(
  491. # )--  Class: Window_MenuCommand  --(
  492. # )---------------------------------(
  493. class Window_MenuCommand < Window_Command
  494.  
  495.   # )-------------------------------------------(
  496.   # )--  Overwrite Method: make_command_list  --(
  497.   # )-------------------------------------------(
  498.   def make_command_list
  499.     add_main_commands
  500.     add_original_commands
  501.     add_save_command
  502.     add_game_end_command
  503.   end
  504.  
  505.   # )-------------------------------------------(
  506.   # )--  Overwrite Method: add_main_commands  --(
  507.   # )-------------------------------------------(
  508.   def add_main_commands
  509.     add_command(Vocab::item,   :item,   main_commands_enabled)
  510.     add_command(Vocab::skill,  :skill,  main_commands_enabled)
  511.     add_command(Vocab::equip,  :equip,  main_commands_enabled)
  512.   end
  513. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement