Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 30.32 KB | None | 0 0
  1. #=============================================================================#
  2. #   Extended Equipment Comparsion Info                                        #
  3. #   Version: 1.0.0                                                            #  
  4. #   Author: Compeador                                                         #  
  5. #   Last update: 2018.10.21                                                   #  
  6. #=============================================================================#
  7. $imported = {} if $imported.nil?
  8. $imported["COMP_EECI"] = true
  9. #=============================================================================#
  10. #                               ** Update log **                              #
  11. #-----------------------------------------------------------------------------#
  12. #                                                                             #
  13. # -- 2018.10.21: First release                                                #
  14. #                                                                             #
  15. #=============================================================================#
  16. #                       ** End-User License Agreement **                      #
  17. #-----------------------------------------------------------------------------#
  18. #  1. Copyright and Redistribution:                                           #
  19. #       All codes were written by me(Compeador), and you(the user) may edit   #
  20. #  the code for your own need without permission (duh).                       #
  21. #  Redistribute this script must agreed by VaiJack8, who commissioned this    #
  22. #  script, and you must share the original version released by the author     #
  23. #  without edits.                                                             #
  24. #                                                                             #
  25. # 2. Service Information:                                                     #
  26. #       I only responsible for the edits requested by VaiJack8(the client).   #
  27. # If you got this script from the redistribution, I'm not responsible for any #
  28. # bug and malfunction occurred in your project.                               #
  29. #                                                                             #
  30. # *You can still try to request me tho, but I won't 100% guaranteed for reply #
  31. #=============================================================================#
  32. #                              ** User Manual **                              #
  33. #-----------------------------------------------------------------------------#
  34. # > Introduction:                                                             #
  35. #       This script will change the display of original parameter comparsion  #
  36. # in Equip Scene when changing the equipments, instead of showing default     #
  37. # paramters, this script will only show changed parameters, including crit.   #
  38. # evasion...etc.                                                              #
  39. #=============================================================================#
  40. #                            ** Compatibility **                              #
  41. #-----------------------------------------------------------------------------#
  42. #   > Require keyboard input script created By Cidiomar R. Dias Junior        #
  43. #   > Compatible with YEA Equip Engine                                        #
  44. #   > Support comparsion with 'Equipment Set Bonuses' by Modern Algebra       #
  45. #                                                                             #
  46. #       ** Place this script below the scripts mentioned above **             #
  47. #=============================================================================#
  48. # > Code compatibility details of classes and methods
  49. #
  50. #   - Window_EquipStatus
  51. #       .contents_height    [overwrite]
  52. #       .refresh            [overwrite]
  53. #       .draw_item          [overwrite]
  54. #       .initialize         [alias]     as: init_ecci
  55. #       .update             [alias]     as: update_ecci
  56. #       .update_scroll      [new]
  57. #       .compare_diff       [new]
  58. #=============================================================================
  59.  
  60.  
  61. #------------------------------------------------------------------------------
  62. # * Check whether Keyboard input script imported, raise inforamtion and disable
  63. #   the script if none.
  64. #------------------------------------------------------------------------------
  65. COMP_EECI_Enable = false
  66. begin
  67.   _ = Input::KEYMAP
  68. rescue => NameError
  69.   info = "Keymap is not detected, please make sure you have keyboard input" +
  70.           " script in your project and placed in right place!\n" +
  71.           "The EECI script will be disabled."
  72.   msgbox(info)
  73.   COMP_EECI_Enable = false
  74. end
  75.  
  76. if COMP_EECI_Enable
  77. #=============================================================================
  78. # * Module of this script
  79. #=============================================================================
  80. module COMP
  81.   #-------------------------------------------------------------------------
  82.   # Abbr. of Extended Equipment Comparsion Information
  83.   module EECI
  84.     #--------------------------------------------------------------------------
  85.     # * Constants (Features) from Game_BattlerBase
  86.     # * Don't edit this unless you know what you're doing
  87.     #--------------------------------------------------------------------------
  88.     FEATURE_ELEMENT_RATE    =   Game_BattlerBase::FEATURE_ELEMENT_RATE    # Element Rate
  89.     FEATURE_DEBUFF_RATE     =   Game_BattlerBase::FEATURE_DEBUFF_RATE     # Debuff Rate
  90.     FEATURE_STATE_RATE      =   Game_BattlerBase::FEATURE_STATE_RATE      # State Rate
  91.     FEATURE_STATE_RESIST    =   Game_BattlerBase::FEATURE_STATE_RESIST    # State Resist
  92.     FEATURE_PARAM           =   Game_BattlerBase::FEATURE_PARAM           # Parameter
  93.     FEATURE_XPARAM          =   Game_BattlerBase::FEATURE_XPARAM          # Ex-Parameter
  94.     FEATURE_SPARAM          =   Game_BattlerBase::FEATURE_SPARAM          # Sp-Parameter
  95.     FEATURE_ATK_ELEMENT     =   Game_BattlerBase::FEATURE_ATK_ELEMENT     # Atk Element
  96.     FEATURE_ATK_STATE       =   Game_BattlerBase::FEATURE_ATK_STATE       # Atk State
  97.     FEATURE_ATK_SPEED       =   Game_BattlerBase::FEATURE_ATK_SPEED       # Atk Speed
  98.     FEATURE_ATK_TIMES       =   Game_BattlerBase::FEATURE_ATK_TIMES       # Atk Times+
  99.     FEATURE_STYPE_ADD       =   Game_BattlerBase::FEATURE_STYPE_ADD       # Add Skill Type
  100.     FEATURE_STYPE_SEAL      =   Game_BattlerBase::FEATURE_STYPE_SEAL      # Disable Skill Type
  101.     FEATURE_SKILL_ADD       =   Game_BattlerBase::FEATURE_SKILL_ADD       # Add Skill
  102.     FEATURE_SKILL_SEAL      =   Game_BattlerBase::FEATURE_SKILL_SEAL      # Disable Skill
  103.     FEATURE_EQUIP_WTYPE     =   Game_BattlerBase::FEATURE_EQUIP_WTYPE     # Equip Weapon
  104.     FEATURE_EQUIP_ATYPE     =   Game_BattlerBase::FEATURE_EQUIP_ATYPE     # Equip Armor
  105.     FEATURE_EQUIP_FIX       =   Game_BattlerBase::FEATURE_EQUIP_FIX       # Lock Equip
  106.     FEATURE_EQUIP_SEAL      =   Game_BattlerBase::FEATURE_EQUIP_SEAL      # Seal Equip
  107.     FEATURE_SLOT_TYPE       =   Game_BattlerBase::FEATURE_SLOT_TYPE       # Slot Type
  108.     FEATURE_ACTION_PLUS     =   Game_BattlerBase::FEATURE_ACTION_PLUS     # Action Times+
  109.     FEATURE_SPECIAL_FLAG    =   Game_BattlerBase::FEATURE_SPECIAL_FLAG    # Special Flag
  110.     FEATURE_COLLAPSE_TYPE   =   Game_BattlerBase::FEATURE_COLLAPSE_TYPE   # Collapse Effect
  111.     FEATURE_PARTY_ABILITY   =   Game_BattlerBase::FEATURE_PARTY_ABILITY   # Party Ability
  112.     # ---Feature Flags---
  113.     FLAG_ID_AUTO_BATTLE     =   Game_BattlerBase::FLAG_ID_AUTO_BATTLE     # auto battle
  114.     FLAG_ID_GUARD           =   Game_BattlerBase::FLAG_ID_GUARD           # guard
  115.     FLAG_ID_SUBSTITUTE      =   Game_BattlerBase::FLAG_ID_SUBSTITUTE      # substitute
  116.     FLAG_ID_PRESERVE_TP     =   Game_BattlerBase::FLAG_ID_PRESERVE_TP     # preserve TP
  117.    
  118.     #=====================================================================
  119.     # * The scroll-up and scroll-down keybind, edit the value for your own
  120.     # need. For example, if you want 'I' and 'K' for scroll up/down,
  121.     # edit the
  122.     # 'Input::KEYMAP[:LETTER_R]' to 'Input::KEYMAP[:LETTER_I]' and
  123.     # 'Input::KEYMAP[:LETTER_F]' to 'Input::KEYMAP[:LETTER_K]'.
  124.     # Take a look at the keyboard script for all supported key and symbol
  125.     #=====================================================================
  126.     Key_scrollup    = Input::KEYMAP[:LETTER_R]
  127.     Key_scrolldown  = Input::KEYMAP[:LETTER_F]
  128.     #---------------------------------------------------------------------
  129.     # * Text displayed when showing the comparsion of set equipment bonus
  130.     SetEquipmentText = "Set bonus:"
  131.     #---------------------------------------------------------------------
  132.     # * Scrolling speed, aka the delta-y per frame
  133.     Scrollspeed     = 4
  134.     #---------------------------------------------------------------------
  135.     # * How many lines of comparsion should be listed at most? If the
  136.     #   differences between two equipments are more than this number, the
  137.     #   surplus won't be displayed.
  138.     MaxDrawLine  = 30
  139.     #---------------------------------------------------------------------
  140.     # * The param/feature considered to compare
  141.     ComparsionTable = {        
  142.       # symbol        => [id,  display text showed in comparsion]
  143.       :param       => [-1, ''],                                     # Basic parameter
  144.       :xparam      => [FEATURE_XPARAM, ''],                         # Ex-Parameter
  145.       :sparam      => [FEATURE_SPARAM, ''],                         # Sp-Parameter
  146.  
  147.       :param_rate     => [FEATURE_PARAM, 'Param multipler'],        # Parameter
  148.       :special_flag   => [FEATURE_SPECIAL_FLAG, 'Special'],         # Special feature flag
  149.       :element_rate   => [FEATURE_ELEMENT_RATE, 'Element Rate'],    # Element Rate
  150.       :debuff_rate    => [FEATURE_DEBUFF_RATE, 'Debuff Rate'],      # Debuff Rate
  151.       :state_rate     => [FEATURE_STATE_RATE, 'State Rate'],        # State Rate
  152.       :state_resist   => [FEATURE_STATE_RESIST, 'State Resist'],    # State Resist
  153.       :atk_element    => [FEATURE_ATK_ELEMENT, 'Atk Element'],      # Atk Element
  154.       :atk_state      => [FEATURE_ATK_STATE, 'Atk State'],          # Atk State
  155.       :atk_speed      => [FEATURE_ATK_SPEED, 'Atk Speed'],          # Atk Speed
  156.       :atk_times      => [FEATURE_ATK_TIMES, 'Atk Times+'],         # Atk Times+
  157.       :stype_add      => [FEATURE_STYPE_ADD, 'Add Skill Type'],     # Add Skill Type
  158.       :stype_seal     => [FEATURE_STYPE_SEAL, 'Disable Skill Type'],# Disable Skill Type
  159.       :skill_add      => [FEATURE_SKILL_ADD, 'Add Skill'],          # Add Skill
  160.       :skill_seal     => [FEATURE_SKILL_SEAL, 'Disable Skill'],     # Disable Skill
  161.       :equip_wtype    => [FEATURE_EQUIP_WTYPE, 'Equip Weapon'],     # Equip Weapon
  162.       :equip_atype    => [FEATURE_EQUIP_ATYPE, 'Equip Armor'],      # Equip Armor
  163.       :equip_fix      => [FEATURE_EQUIP_FIX, 'Lock Equip'],         # Lock Equip
  164.       :equip_seal     => [FEATURE_EQUIP_SEAL, 'Seal Equip'],        # Seal Equip
  165.       :slot_type      => [FEATURE_SLOT_TYPE, 'Slot Type'],          # Slot Type
  166.       :action_plus    => [FEATURE_ACTION_PLUS, 'Action Times+'],    # Action Times+
  167.       :party_ability  => [FEATURE_PARTY_ABILITY, 'Party ability'],  # Party ability
  168.       # --- Special Feature Flags ---
  169.       :flag_id_auto_battle    => [FLAG_ID_AUTO_BATTLE, 'Special'],       # auto battle
  170.       :flag_id_guard          => [FLAG_ID_GUARD, 'Special'],             # guard
  171.       :flag_id_substitute     => [FLAG_ID_SUBSTITUTE, 'Special'],        # substitute
  172.       :flag_id_preserve_tp    => [FLAG_ID_PRESERVE_TP, 'Special'],       # preserve TP
  173.     }
  174.     #---------------------------------------------------------------------
  175.     # * Display order of compastion text,
  176.     MISC_text = 'Other'
  177.     TextDisplayOrder = [
  178.       '',         # suggestion: better not touch this line
  179.       'Feature',
  180.       'Special',
  181.       'Param multipler',
  182.       'Element Rate',
  183.       'Debuff Rate',
  184.       'State Rate',
  185.       'State Resist',
  186.       'Atk Element',
  187.       'Atk State',
  188.       'Atk Speed',
  189.       'Atk Times+',
  190.       'Add Skill Type',
  191.       'Disable Skill Type',
  192.       'Add Skill',
  193.       'Disable Skill',
  194.       'Equip Weapon',
  195.       'Equip Armor',
  196.       'Lock Equip',
  197.       'Seal Equip',
  198.       'Slot Type',
  199.       'Action Times+',
  200.       'Party ability',
  201.       MISC_text,
  202.     ]
  203.     #---------------------------------------------------------------------
  204.     # * Name display for each xparam
  205.     XParamName = {
  206.       0   => "HIT",  # HIT rate
  207.       1   => "EVA",  # EVAsion rate
  208.       2   => "CRI",  # CRItical rate
  209.       3   => "CEV",  # Critical EVasion rate
  210.       4   => "MEV",  # Magic EVasion rate
  211.       5   => "MRF",  # Magic ReFlection rate
  212.       6   => "CNT",  # CouNTer attack rate
  213.       7   => "HRG",  # Hp ReGeneration rate
  214.       8   => "MRG",  # Mp ReGeneration rate
  215.       9   => "TRG",  # Tp ReGeneration rate
  216.     }
  217.     #---------------------------------------------------------------------
  218.     # * Name display for each sparam
  219.     SParamName = {
  220.       0   => "TGR",  # TarGet Rate
  221.       1   => "GRD",  # GuaRD effect rate
  222.       2   => "REC",  # RECovery effect rate
  223.       3   => "PHA",  # PHArmacology
  224.       4   => "MCR",  # Mp Cost Rate
  225.       5   => "TCR",  # Tp Charge Rate
  226.       6   => "PDR",  # Physical Damage Rate
  227.       7   => "MDR",  # Magical Damage Rate
  228.       8   => "FDR",  # Floor Damage Rate
  229.       9   => "EXR",  # EXperience Rate
  230.     }
  231.     #---------------------------------------------------------------------
  232.     # * Name display for party ability
  233.     PartyAbilityName = {
  234.       0   => "Encounter Half",          # halve encounters
  235.       1   => "Encounter None",          # disable encounters
  236.       2   => "Cancel Surprise",         # disable surprise
  237.       3   => "Raise Preemptive",        # increase preemptive strike rate
  238.       4   => "Gold Double",             # double money earned
  239.       5   => "Item Drop Rate Double",   # double item acquisition rate
  240.     }
  241.     #---------------------------------------------------------------------
  242.     # * Name display for special feature
  243.     SpecialFeatureName = {
  244.       0 => "Auto Battle",
  245.       1 => "Guard",
  246.       2 => "Substitute",
  247.       3 => "Preserve TP",
  248.     }
  249.     #---------------------------------------------------------------------
  250.     # * prefix of single feature comparsion
  251.     FeatureAddText     = "+ %s"
  252.     FeatureRemoveText  = "- %s"
  253.     FeatureEnableText  = "√ %s"
  254.     FeatureDisableText = "X %s"
  255.     #---------------------------------------------------------------------
  256.     InverseColorFeature = [FEATURE_STYPE_SEAL, FEATURE_SKILL_SEAL]
  257.     PercentageFeaure = [
  258.       FEATURE_ELEMENT_RATE, FEATURE_DEBUFF_RATE, FEATURE_STATE_RATE,
  259.       FEATURE_PARAM, FEATURE_XPARAM, FEATURE_SPARAM, FEATURE_ATK_STATE,
  260.       FEATURE_ACTION_PLUS,
  261.     ]
  262.     #=====================================================================#
  263.     # Please don't edit anything below unless you know what you're doing! #
  264.     #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
  265.  
  266.     # Strcuture holds compare result of each difference
  267.     DiffInfo = Struct.new(:feature_id, :data_id, :value, :display_str)
  268.     # :feature_id > what do you expect me to say?
  269.     # :data_id    > data id in grouped feature, such as param
  270.     # :delta      > value changed of that feature, in certain feature id is:
  271.     #   true/false  = add/remove after equip
  272.     # :display_str > Other text displayed
  273.  
  274.    
  275.     #--------------------------------------------------------------------------
  276.     # * Feature needn't iterated, show in one line
  277.     SingularFeature = [
  278.       FEATURE_ATK_SPEED,
  279.       FEATURE_ATK_TIMES,
  280.       FEATURE_ACTION_PLUS,
  281.     ]
  282.     #--------------------------------------------------------------------------
  283.     # * Mapping table for easier query
  284.     StringTable  = {}
  285.     DisplayOrder = {}
  286.     ComparsionTable.each{|k, v| StringTable[v[0]] = v[1]}
  287.     TextDisplayOrder.each_with_index{|v,i| DisplayOrder[v] = i}
  288.   end
  289. end
  290.  
  291. #==============================================================================
  292. # ** Game_Actor
  293. #==============================================================================
  294. class Game_Actor < Game_Battler
  295. end
  296.  
  297. #==============================================================================
  298. # ** Window_EquipStatus
  299. #------------------------------------------------------------------------------
  300. #  This window displays actor parameter changes on the equipment screen.
  301. #==============================================================================
  302. class Window_EquipStatus < Window_Base
  303.   include COMP::EECI
  304.   EQS_Enable = $imported[:MA_EquipmentSetBonuses]
  305.   #---------------------------------------------------------------------------
  306.   # * Instance variables
  307.   #---------------------------------------------------------------------------
  308.   attr_reader :difference
  309.   attr_reader :set_difference if EQS_Enable
  310.   #---------------------------------------------------------------------------
  311.   # * Alias method: initialize
  312.   #---------------------------------------------------------------------------
  313.   alias init_eeci initialize
  314.   def initialize(*args)
  315.     @bottom_oy      = 1
  316.     @difference     = {}
  317.     init_eeci(*args)
  318.     @visible_height = height - standard_padding * 2
  319.   end
  320.   #---------------------------------------------------------------------------
  321.   # * Overwrite methods: contents height
  322.   #---------------------------------------------------------------------------
  323.   def contents_height
  324.     @bottom_oy
  325.   end
  326.   #---------------------------------------------------------------------------
  327.   # * Alias method: update
  328.   #---------------------------------------------------------------------------
  329.   alias update_eeci update
  330.   def update
  331.     update_eeci
  332.     update_scroll
  333.   end
  334.   #---------------------------------------------------------------------------
  335.   # * New method: update scroll
  336.   #---------------------------------------------------------------------------
  337.   def update_scroll
  338.     return unless self.arrows_visible
  339.     delta = Scrollspeed
  340.     delta *= 3 if Input.press?(Input::SHIFT)
  341.     if Input.trigger?(Key_scrollup) || Input.press?(Key_scrollup)
  342.       self.oy = [self.oy - delta, 0].max if self.oy > 0
  343.     elsif Input.trigger?(Key_scrolldown) || Input.press?(Key_scrolldown)
  344.       by = [@bottom_oy + 4 - @visible_height, 0].max
  345.       self.oy = [self.oy + delta, by].min if self.oy < by
  346.     end
  347.  
  348.   end
  349.   #---------------------------------------------------------------------------
  350.   # * Overwrite method: refresh
  351.   #---------------------------------------------------------------------------
  352.   def refresh        
  353.     contents.clear
  354.     self.oy    = 0
  355.     @bottom_oy = 1
  356.     self.arrows_visible = false
  357.     @difference.clear
  358.     return unless @temp_actor && @actor
  359.     compare_diffs
  360.     line_number  = @difference.keys.count{|k| (@difference[k] || []).size > 0 && StringTable[k].length > 0}
  361.     line_number += @difference.values.flatten.size
  362.     @bottom_oy   = ([line_number, MaxDrawLine].min) * line_height
  363.     create_contents
  364.     self.arrows_visible = @bottom_oy > @visible_height
  365.     draw_comapre_result
  366.   end
  367.   #---------------------------------------------------------------------------
  368.   def compare_diffs
  369.     en_prefix   = [FeatureDisableText, FeatureEnableText]
  370.     ComparsionTable.each do |symbol, info|
  371.       feature_id  = info[0]
  372.       display_str = info[1]
  373.       case symbol
  374.       when :param;        compare_param();
  375.       when :param_rate;   compare_valued_feature(feature_id, true)
  376.       when :xparam;       compare_features_sum(feature_id);
  377.       when :sparam;       compare_features_pi(feature_id);
  378.       when :skill_add;    compare_features_set(feature_id);
  379.       when :skill_seal;   compare_features_set(feature_id, en_prefix.reverse);
  380.       when :element_rate; compare_features_pi(feature_id);
  381.       when :atk_element;  compare_features_set(feature_id);
  382.       when :atk_state;    compare_valued_feature(feature_id, false);
  383.       when :state_rate;   compare_features_pi(feature_id);
  384.       when :state_resist; compare_features_set(feature_id);
  385.       when :stype_seal;   compare_features_set(feature_id, en_prefix.reverse);
  386.       when :stype_add;    compare_features_set(feature_id, en_prefix);
  387.       when :atk_speed;    compare_features_sum(feature_id);
  388.       when :atk_times;    compare_features_sum(feature_id);
  389.       when :action_plus;  compare_action_plus(feature_id);
  390.       when :special_flag; compare_special_flag(feature_id);
  391.       when :party_ability;compare_party_ability(feature_id);
  392.       end
  393.     end # ComparsionTable.each
  394.   end
  395.   #---------------------------------------------------------------------------
  396.   def compare_param(feature_id = FEATURE_PARAM)
  397.     ar = get_feature_array(feature_id)
  398.     len = ar.size
  399.     len.times do |i|
  400.       a = @temp_actor.param(i)
  401.       b = @actor.param(i)
  402.       next if a - b == 0
  403.       str = get_feature_name(feature_id, i)
  404.       (@difference[-1] ||= []) << DiffInfo.new(-1, i, [a,b], str)
  405.     end
  406.   end
  407.   #---------------------------------------------------------------------------
  408.   def compare_features_sum(feature_id)
  409.     ar = get_feature_array(feature_id); len = ar.size;
  410.     if len == 0
  411.       a = @temp_actor.features_sum_all(feature_id)
  412.       b = @actor.features_sum_all(feature_id)
  413.       delta = (a - b)
  414.       delta = delta.round(2) if delta.is_a?(Float)
  415.       return if delta == 0
  416.       str = get_feature_name(feature_id)
  417.       (@difference[feature_id] ||= []) << DiffInfo.new(feature_id, 0, [a,b], str)
  418.     else
  419.       len.times do |i|
  420.         a = @temp_actor.features_sum(feature_id, i)
  421.         b = @actor.features_sum(feature_id, i)
  422.         delta = (a - b)
  423.         delta = delta.round(2) if delta.is_a?(Float)
  424.         next if delta == 0
  425.         str = get_feature_name(feature_id, i)
  426.         (@difference[feature_id] ||= []) << DiffInfo.new(feature_id, i, [a,b], str)
  427.       end
  428.     end
  429.   end
  430.   #---------------------------------------------------------------------------
  431.   def compare_features_pi(feature_id)
  432.     ar = get_feature_array(feature_id); len = ar.size;
  433.     len.times do |i|
  434.       a = @temp_actor.features_pi(feature_id, i)
  435.       b = @actor.features_pi(feature_id, i)
  436.       delta = (a - b)
  437.       delta = delta.round(2) if delta.is_a?(Float)
  438.       next if delta == 0
  439.       str = get_feature_name(feature_id, i)
  440.       (@difference[feature_id] ||= []) << DiffInfo.new(feature_id, i, [a,b], str)
  441.     end
  442.   end
  443.   #---------------------------------------------------------------------------
  444.   def compare_features_set(feature_id, prefix = [FeatureRemoveText, FeatureAddText])
  445.     before = @actor.features_set(feature_id)
  446.     after  = @temp_actor.features_set(feature_id)
  447.  
  448.     after.select{|id| !before.include?(id)}.each do |id|
  449.       str = sprintf(prefix[1], get_feature_name(feature_id, id))
  450.       (@difference[feature_id] ||= []) << DiffInfo.new(feature_id, id,  true, str)
  451.     end
  452.  
  453.     before.select{|id| !after.include?(id)}.each do |id|
  454.       str = sprintf(prefix[0], get_feature_name(feature_id, id))
  455.       (@difference[feature_id] ||= []) << DiffInfo.new(feature_id, id, false, str)
  456.     end
  457.   end
  458.   #---------------------------------------------------------------------------
  459.   def compare_valued_feature(feature_id, pi)
  460.     before = @actor.features_set(feature_id)
  461.     after  = @temp_actor.features_set(feature_id)
  462.     prefix = [FeatureRemoveText, FeatureAddText]
  463.     (after + before).uniq.sort.each do |id|
  464.       a = pi ? @temp_actor.features_pi(feature_id, id) : @temp_actor.features_sum(feature_id, id)
  465.       b = pi ? @actor.features_pi(feature_id, id) : @actor.features_sum(feature_id, id)
  466.       next if a - b == 0
  467.       str = get_feature_name(feature_id, id)
  468.       (@difference[feature_id] ||= []) << DiffInfo.new(feature_id, id, [a,b], str)
  469.     end
  470.   end
  471.   #---------------------------------------------------------------------------
  472.   def compare_action_plus(feature_id)
  473.   end
  474.   #---------------------------------------------------------------------------
  475.   def compare_special_flag(feature_id)
  476.   end
  477.   #---------------------------------------------------------------------------
  478.   def compare_party_ability(feature_id)
  479.   end
  480.   #---------------------------------------------------------------------------
  481.   def get_feature_name(feature_id, index = nil)
  482.     case feature_id
  483.     when FEATURE_ATK_ELEMENT;   return $data_system.elements[index];
  484.     when FEATURE_ELEMENT_RATE;  return $data_system.elements[index];
  485.     when FEATURE_PARAM;         return Vocab.param(index);
  486.     when FEATURE_XPARAM;        return XParamName[index];
  487.     when FEATURE_SPARAM;        return SParamName[index];
  488.     when FEATURE_SKILL_ADD;     return $data_skills[index].name;
  489.     when FEATURE_SKILL_SEAL;    return $data_skills[index].name;
  490.     when FEATURE_STATE_RATE;    return $data_states[index].name;
  491.     when FEATURE_STATE_RESIST;  return $data_states[index].name;
  492.     when FEATURE_ATK_STATE;     return $data_states[index].name;
  493.     when FEATURE_EQUIP_WTYPE;   return $data_system.weapon_types[index];
  494.     when FEATURE_EQUIP_WTYPE;   return $data_system.armor_types[index];
  495.     when FEATURE_STYPE_ADD;     return $data_system.skill_types[index];
  496.     when FEATURE_STYPE_SEAL;    return $data_system.skill_types[index];
  497.     else
  498.       return ""
  499.     end
  500.   end
  501.   #---------------------------------------------------------------------------
  502.   def get_feature_array(feature_id)
  503.     case feature_id
  504.     when FEATURE_ATK_ELEMENT;   return $data_system.elements;
  505.     when FEATURE_ELEMENT_RATE;  return $data_system.elements;
  506.     when FEATURE_PARAM;         return Array.new($data_system.terms.params.size, 0);
  507.     when FEATURE_XPARAM;        return Array.new(XParamName.size, 0);
  508.     when FEATURE_SPARAM;        return Array.new(SParamName.size);
  509.     when FEATURE_SKILL_ADD;     return $data_skills;
  510.     when FEATURE_SKILL_SEAL;    return $data_skills;
  511.     when FEATURE_STATE_RATE;    return $data_states;
  512.     when FEATURE_STATE_RESIST;  return $data_states;
  513.     when FEATURE_ATK_STATE;     return $data_states;
  514.     when FEATURE_EQUIP_WTYPE;   return $data_system.weapon_types;
  515.     when FEATURE_EQUIP_WTYPE;   return $data_system.armor_types;
  516.     when FEATURE_STYPE_ADD;     return $data_system.skill_types;
  517.     when FEATURE_STYPE_SEAL;    return $data_system.skill_types;
  518.     else
  519.       return []
  520.     end
  521.   end
  522.   #---------------------------------------------------------------------------
  523.   def draw_comapre_result
  524.     counter = 0
  525.    
  526.     diff = @difference.sort_by{|k, dar|
  527.       DisplayOrder[StringTable[dar.first.feature_id]] ? DisplayOrder[StringTable[dar.first.feature_id]] : DisplayOrder[MISC_text]
  528.     }.collect{|p| p[1]}
  529.     last_display_group = ''
  530.     diff.each do |infos|
  531.       feature_id = infos.first.feature_id
  532.       group_text = StringTable[feature_id]
  533.       if last_display_group != group_text && group_text.length > 0
  534.         last_display_group = group_text
  535.         rect = Rect.new(0, counter * line_height, contents_width, line_height)
  536.         draw_text(rect, group_text)
  537.         counter += 1
  538.       end
  539.       infos.each do |info|
  540.         dy = counter * line_height
  541.         break if dy > @bottom_oy + 1
  542.         draw_item(0, dy, info)
  543.         counter += 1
  544.       end
  545.     end
  546.   end
  547.   #---------------------------------------------------------------------------
  548.   # * Overwrite: draw_item
  549.   #---------------------------------------------------------------------------
  550.   def draw_item(dx, dy, info)
  551.     # YEA Equip Engine code
  552.     if $imported["YEA-AceEquipEngine"]
  553.       self.contents.font.size = YEA::EQUIP::STATUS_FONT_SIZE
  554.       draw_background_colour(dx, dy)
  555.     end
  556.  
  557.     # Draw feature add/remove
  558.     if info.value == true || info.value == false
  559.       # Inverse the color effect if feature is not good
  560.       inverse = (InverseColorFeature.include?(info.feature_id)) ? 1 : 0
  561.       a = (info.value ? 1 : 0) ^ inverse
  562.       b = (info.value ? 0 : 1) ^ inverse
  563.       change_color(param_change_color(a - b))
  564.  
  565.       # draw skill change with the icon
  566.       if [FEATURE_SKILL_ADD, FEATURE_SKILL_SEAL].include?(info.feature_id)
  567.         info.value ^= inverse
  568.         draw_skill_change(dx + 8, dy, info)
  569.       else
  570.         draw_info_change(dx + 8, dy, info.display_str)
  571.       end
  572.       change_color(normal_color)
  573.     else
  574.       draw_info_name(dx + 4, dy, info.display_str)
  575.       draw_info_diff(dx + 8, dy, info.value, PercentageFeaure.include?(info.feature_id))
  576.     end
  577.     reset_font_settings if $imported["YEA-AceEquipEngine"]
  578.   end
  579.   #---------------------------------------------------------------------------
  580.   def draw_info_change(dx, dy, str)
  581.     rect = Rect.new(0, dy, contents.width-4, line_height)
  582.     draw_text(rect, str, 2)
  583.   end
  584.   #---------------------------------------------------------------------------
  585.   def draw_skill_change(dx, dy, info)
  586.     str = info.display_str
  587.     return draw_info_change(dx, dy, str) unless (info.data_id || 0) > 0
  588.     text_width = self.contents.text_size(str).width
  589.     dx = contents.width - text_width - 34
  590.     prefix = str[0]; str = str[1...str.length];
  591.     rect = Rect.new(dx, dy, self.contents.text_size(prefix).width + 3, line_height)
  592.     draw_text(rect, prefix)
  593.     offset = rect.width + 24
  594.     draw_icon($data_skills[info.data_id].icon_index, dx + rect.width, dy, info.value)
  595.     rect.x += offset; rect.width = text_width;
  596.     draw_text(rect, str)
  597.   end
  598.   #---------------------------------------------------------------------------
  599.   def draw_info_name(dx, dy, str)
  600.     change_color(system_color)
  601.     draw_text(dx, dy, contents.width, line_height, str)
  602.     change_color(normal_color)
  603.   end
  604.   #---------------------------------------------------------------------------
  605.   def draw_info_diff(dx, dy, value, is_percent = false)
  606.     dw = (contents.width + 22) / 2
  607.     crect = Rect.new(0, dy, dw, line_height)
  608.     nrect = Rect.new(0, dy, contents.width-4, line_height)
  609.     drx = (contents.width + 22) / 2
  610.     draw_diff_value(crect, value[1], is_percent)
  611.     draw_right_arrow(drx, dy)
  612.     change_color(param_change_color(value[0] - value[1]))
  613.     draw_diff_value(nrect, value[0], is_percent)
  614.     change_color(normal_color)
  615.   end
  616.   #---------------------------------------------------------------------------
  617.   def draw_diff_value(rect, value, is_percent)
  618.     str = value.to_s
  619.     str = sprintf("%s\%", (value * 100).to_i) if is_percent
  620.     draw_text(rect, str, 2)
  621.   end
  622.   #---------------------------------------------------------------------------
  623. end # class Window_EQ status
  624. end # enable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement