Guest User

Untitled

a guest
Nov 20th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 16.34 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.     call_update_help
  255.   end
  256.  
  257.   # )-----------------------(
  258.   # )--  Method: col_max  --(
  259.   # )-----------------------(
  260.   def col_max
  261.     return 1
  262.   end
  263.  
  264.   # )--------------------------------(
  265.   # )--  Method: call_update_help  --(
  266.   # )--------------------------------(
  267.   def call_update_help
  268.     update_help
  269.   end
  270.  
  271.   # )---------------------------(
  272.   # )--  Method: update_help  --(
  273.   # )---------------------------(
  274.   def update_help
  275.     @help_window.set_item(item) if @help_window
  276.  
  277.     if @actor && @status_window
  278.       temp_actor = Marshal.load(Marshal.dump(@actor))
  279.       temp_actor.force_change_equip(@slot_id, item)
  280.       status_window.set_temp_actor(temp_actor)
  281.     end
  282.   end
  283.  
  284.  
  285. end
  286.  
  287.  
  288. #)------------------------------------(
  289. #)--  Class: MrTS_Equipment_Window  --(
  290. #)------------------------------------(
  291. class MrTS_Equipment_Window < Window_EquipSlot
  292.  
  293.   attr_reader :status_window
  294.  
  295.   # )------------------------------------(
  296.   # )--  Overwrite Method: initialize  --(
  297.   # )------------------------------------(
  298.   def initialize(x)
  299.     super(x, 96 + line_height * 7, Graphics.width-160)
  300.     @actor = $game_party.leader
  301.     create_contents
  302.     refresh
  303.   end
  304.  
  305.   # )------------------------------------------(
  306.   # )--  Overwrite Method: call_update_help  --(
  307.   # )------------------------------------------(
  308.   def call_update_help
  309.     update_help
  310.   end
  311.  
  312.   # )-------------------------------------(
  313.   # )--  Overwrite Method: update_help  --(
  314.   # )-------------------------------------(
  315.   def update_help
  316.     status_window.set_temp_actor(nil) if @status_window
  317.   end
  318. end
  319.  
  320.  
  321. #)--------------------------------------(
  322. #)--  Class: MrTS_Window_Solo_Status  --(
  323. #)--------------------------------------(
  324. class MrTS_Window_Solo_Status < Window_Base
  325.  
  326.   # )--------------------------(
  327.   # )--  Method: initialize  --(
  328.   # )--------------------------(
  329.   def initialize(x, y)
  330.     super(x, y, window_width, window_height)
  331.     @pending_index = -1
  332.     @temp_actor = nil
  333.     @actor = $game_party.leader
  334.     refresh
  335.   end
  336.  
  337.   # )----------------------------(
  338.   # )--  Method: window_width  --(
  339.   # )----------------------------(
  340.   def window_width
  341.     Graphics.width - 160
  342.   end
  343.  
  344.   # )-----------------------------(
  345.   # )--  Method: window_height  --(
  346.   # )-----------------------------(
  347.   def window_height
  348.     Graphics.height
  349.   end
  350.  
  351.   # )--------------------------------(
  352.   # )--  Method: draw_actor_param  --(
  353.   # )--------------------------------(
  354.   def draw_actor_param(actor, x, y, param_id, color = normal_color)
  355.     change_color(system_color)
  356.     draw_text(x, y, 120, line_height, Vocab::param(param_id))
  357.     change_color(color)
  358.     draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2)
  359.     change_color(normal_color)
  360.   end
  361.  
  362.   # )-----------------------------(
  363.   # )--  Method: draw_actor_hp  --(
  364.   # )-----------------------------(
  365.   def draw_actor_hp(actor, x, y, width = 124, color = normal_color)
  366.     draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  367.     change_color(system_color)
  368.     draw_text(x, y, 30, line_height, Vocab::hp_a)
  369.     draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
  370.       hp_color(actor), color)
  371.     end
  372.    
  373.   # )-----------------------------(
  374.   # )--  Method: draw_actor_mp  --(
  375.   # )-----------------------------(
  376.   def draw_actor_mp(actor, x, y, width = 124, color = normal_color)
  377.     draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
  378.     change_color(system_color)
  379.     draw_text(x, y, 30, line_height, Vocab::mp_a)
  380.     draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
  381.       mp_color(actor), color)
  382.   end
  383.  
  384.   # )-----------------------(
  385.   # )--  Method: refresh  --(
  386.   # )-----------------------(
  387.   def refresh
  388.     contents.clear
  389.     create_contents
  390.    
  391.     temp_color = normal_color
  392.    
  393.     draw_actor_face(@actor, 0, 0)
  394.     draw_actor_level(@actor, 96, 0)
  395.     draw_actor_name(@actor, 96, line_height)
  396.     draw_actor_class(@actor, 96, line_height*2)
  397.     if !$imported["MrTS_Thirst"]
  398.       draw_actor_xp(@actor, contents.width-160, line_height*2, 160)
  399.     elsif $imported["MrTS_Thirst"]
  400.       draw_thirst_gauge(@actor, contents.width-160, line_height*2, 160)
  401.     end    
  402.    
  403.     if @temp_actor == nil
  404.       draw_actor_hp(@actor, contents.width-160, 0, 160)
  405.       draw_actor_mp(@actor, contents.width-160, line_height, 160)
  406.     else
  407.       temp_color = param_change_color(@temp_actor.param(0)-@actor.param(0))
  408.       draw_actor_hp(@temp_actor, contents.width-160, 0, 160, temp_color)
  409.      
  410.       temp_color = param_change_color(@temp_actor.param(1)-@actor.param(1))
  411.       draw_actor_mp(@temp_actor, contents.width-160, line_height, 160, temp_color)
  412.     end
  413.    
  414.     #params
  415.     6.times do |i|
  416.       contents.gradient_fill_rect(-3, 96+line_height*i, 159, line_height-10, text_color(15), text_color(19))
  417.       dy = 96 + line_height * i
  418.      
  419.       if @temp_actor == nil
  420.         draw_actor_param(@actor, 0, dy, i + 2)
  421.       else
  422.         temp_color = param_change_color(@temp_actor.param(i+2)-@actor.param(i+2))
  423.         draw_actor_param(@temp_actor, 0, 96 + line_height * (i), i+2, temp_color)
  424.       end
  425.     end
  426.    
  427.     #xparams
  428.     skipped = 0
  429.     ignore = MrTS::Data::IGNORE #ignore these xparams
  430.     10.times do |i|
  431.       if !ignore.include?(i)
  432.         if @temp_actor == nil
  433.           draw_actor_xparam(@actor, contents.width-156, 96 + line_height * (i - skipped), i)
  434.         else
  435.           temp_color = param_change_color(@temp_actor.xparam(i)-@actor.xparam(i))
  436.           draw_actor_xparam(@temp_actor, contents.width-156, 96 + line_height * (i - skipped), i, temp_color)
  437.         end
  438.        
  439.       else
  440.         skipped += 1
  441.       end
  442.     end
  443.   end # of refresh
  444.  
  445.   # )---------------------------------(
  446.   # )--  Method: draw_actor_xparam  --(
  447.   # )---------------------------------(
  448.   def draw_actor_xparam(actor, x, y, param_id, color = normal_color)
  449.     contents.gradient_fill_rect(x-3, y, 159, line_height-10, text_color(15), text_color(19))
  450.     change_color(system_color)
  451.     draw_text(x, y, 120, line_height, MrTS::Vocab::XPARAMS[param_id])
  452.     change_color(color)
  453.     draw_text(x + 120 - 36, y, 72, line_height, (actor.xparam(param_id)*100).to_i.to_s + "%", 2)
  454.   end
  455.  
  456.   # )-----------------------------(
  457.   # )--  Method: draw_actor_xp  --(
  458.   # )-----------------------------(
  459.   def draw_actor_xp(actor, x, y, width = 124)
  460.     float = 1.0 * (actor.exp - actor.current_level_exp) / (actor.next_level_exp - actor.current_level_exp)
  461.     draw_gauge(x, y, width, float, text_color(28), text_color(29))
  462.     change_color(system_color)
  463.     draw_text(x, y, 30, line_height, "EXP")
  464.     change_color(normal_color)
  465.     draw_text(x + width - 140, y, (140-12)/2, line_height, actor.exp - actor.current_level_exp, 2)
  466.     draw_text(x+ width - 140/2, y, 12, line_height, "/", 2)
  467.     draw_text(x+ width - (140-12)/2, y, (140-12)/2, line_height, actor.next_level_exp - actor.current_level_exp, 2)
  468.   end
  469.  
  470.   # )------------------------------(
  471.   # )--  Method: set_temp_actor  --(
  472.   # )------------------------------(
  473.   def set_temp_actor(temp_actor)
  474.     return if @temp_actor == temp_actor
  475.     @temp_actor = temp_actor
  476.     refresh
  477.   end
  478.  
  479.   # )----------------------(
  480.   # )--  Method: actor=  --(
  481.   # )----------------------(
  482.   def actor=(actor)
  483.     return if @actor == actor
  484.     @actor = actor
  485.     refresh
  486.   end
  487.  
  488. end
  489.  
  490.  
  491. # )---------------------------------(
  492. # )--  Class: Window_MenuCommand  --(
  493. # )---------------------------------(
  494. class Window_MenuCommand < Window_Command
  495.  
  496.   # )-------------------------------------------(
  497.   # )--  Overwrite Method: make_command_list  --(
  498.   # )-------------------------------------------(
  499.   def make_command_list
  500.     add_main_commands
  501.     add_original_commands
  502.     add_save_command
  503.     add_game_end_command
  504.   end
  505.  
  506.   # )-------------------------------------------(
  507.   # )--  Overwrite Method: add_main_commands  --(
  508.   # )-------------------------------------------(
  509.   def add_main_commands
  510.     add_command(Vocab::item,   :item,   main_commands_enabled)
  511.     add_command(Vocab::skill,  :skill,  main_commands_enabled)
  512.     add_command(Vocab::equip,  :equip,  main_commands_enabled)
  513.   end
  514. end
Advertisement
Add Comment
Please, Sign In to add comment