modern_algebra

Luck Stat

Apr 24th, 2011
338
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #    Luck Stat
  3. #    Version: 1.0a
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: Easter Sunday, 2011
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #
  9. #   Chances are you've never thought about this, but there are a lot of random
  10. #  things going on in RMVX. Which items drop when you kill monsters; if states
  11. #  are applied or released; whether you hit or miss or evade or land a critical
  12. #  hit, all of these things are random. This script adds a new statistic which
  13. #  is intended to modify the chances of these various things happening: Luck!
  14. #  It also makes gold drop amounts random and affects that as well.
  15. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  16. #  Instructions:
  17. #
  18. #   In order to add this script to your game, simply paste it into it its own
  19. #   slot in the Script Editor (F11) above Main but below other custom scripts.
  20. #
  21. #   Roll on down to line 77 for more detailed configuration, but in brief:
  22. #  line 79 is where you change the label for the stat. You can set whether it
  23. #  is shown in the Status scene at line 80 (and where at lines 81 and 83). To
  24. #  see it in the Equip scene, you can set line 88 to true. The most important
  25. #  one is at line 91, where you set the growth for the luck stat of each actor.
  26. #
  27. #   There are also a number of note tags you can use. For any item or state,
  28. #  you can use the following codes (where x and y are integers):
  29. #        \luck[x]
  30. #        \luck[y%]
  31. #  The first adds x directly to the actor's luck, while the second adds that
  32. #  percentage of the actor's total current luck to itself. For weapons and
  33. #  armors, this will happen immediately and only for as long as the armor is
  34. #  equipped. They can also be combined and then the equipment will add (y% + x)
  35. #  luck to the actor when it is equipped. For items, the luck will be added
  36. #  permanently once the item us used, just like for the regular stats. For
  37. #  states, the luck changes will only apply so long as the state is applied. As
  38. #  well for states, you can set a tag to identify whether the state has a
  39. #  positive or negative effect. This is so your luck stat can make it more
  40. #  likely to contract the positive states and less likely to contract the
  41. #  negative ones. In order to identify a state as positive, use this:
  42. #        \positive
  43. #  If not identified as positive, it will assume the state is negative.
  44. #
  45. #   In terms of how this stat should affect how you plan out the game, the stat
  46. #  is intended to be used at lower values - it can work for higher values as
  47. #  well, but it will generally become less effective. The easiest way to think
  48. #  of the stat is as the chance to get more chances. So, if an actor has 50
  49. #  luck and a 4% chance to critical, the Luck stat is a 50% chance to get
  50. #  another 4% chance to critical if you miss the first time. When your luck
  51. #  goes over 100, then you will automatically get a second chance and the
  52. #  remainder is the chance to have a third chance (or fourth, fifth, etc...).
  53. #  So if luck is 225, then it would be three chances at 4% and a 25% chance to
  54. #  have a fourth chance. It affects gold differently. For that, it simply takes
  55. #  the mean average of the party's luck and you randomly get somewhere between
  56. #  0 and that percentage extra gold. So if the gold drop would be 70 and your
  57. #  party has an average luck of 50, then you would get anywhere between 70 and
  58. #  105 gold.
  59. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  60. #  Compatibility:
  61. #    TDS Weapon Unleash - This script should function and modify the chance to
  62. #      unleash. Must place Luck below Weapon Unleash though
  63. #    MA Note Editor - this will work with the Note Editor as long as you have
  64. #      the note editor's general compatibility patch and it's above this script
  65. #    MA FSCMS - The Luck Stat will show up in the Status window
  66. #    YEM Status Menu - You can set the icon at line 124 and the stat should
  67. #     show up in the scene, but it will be cut off if there isn't room for it.
  68. #    YEM Equipment Overhaul - You can set the icon at line 124 and the luck
  69. #     stat should show up, but it will be cut off if there isn't room for it.
  70. #    Others - There shouldn't be errors as long as the Luck script is below
  71. #      them, but it might not function exactly as expected if those scripts
  72. #      vastly alter battles or change the status or equip scenes. If you notice
  73. #      anything odd, please post in my topic and I will try to help.
  74. #==============================================================================
  75.  
  76. #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  77. #    EDITABLE REGION
  78. #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  79. MALS_VOCAB_LUCK = "LUK" # The label to identify the stat in Status and Equip
  80. MALS_STATUS_SHOW = true # Whether to show Luck in Status
  81. MALS_STATUS_X = -1      #  The x position of luck in the status window. When -1,
  82.                         # it will be at the same x as the other parameters
  83. MALS_STATUS_Y = -1      #  The y position of luck in the status window. When -1,
  84.                         # it will be just below other stats. If more negative,
  85.                         # it will be below the other stats + the absolute value
  86.                         # of this. This is so you can reposition it if you have
  87.                         # other added stats.
  88. MALS_EQUIP_SHOW = true  #  Whether to show Luck in the Equip Scene. This will
  89.                         # likely not work with anything but the default scene
  90.                         # and YEM Equip Menu
  91. MALS_LUCK_GROWTH = { # <- Do not touch
  92. #  MALS_LUCK_GROWTH - this is where you can set the level growth of the luck
  93. # for every actor. You can do it in a few ways: either by an array where you
  94. # set it individually for each level, or by a formula encapsulated in quotation
  95. # marks. The 0 => line will be the default growth if you don't set a specific
  96. # one for the actor, while each subsequent line (1 =>; 2 =>) will be the growth
  97. # for the actor with that ID. Remember to put a comma at the end of each.
  98. #   EXAMPLES:
  99. #     0 => "4 * level / 3",
  100. #       This is the default growth and it will mean the actor gains 1 luck
  101. #      every level and 2 every third level.
  102. #     8 => "3 + (level*2)",
  103. #       This would be the growth for Actor 8 and he or she would start out with
  104. #      5 luck and gain 2 more every level.
  105. #     5 => [5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 22, 23, 25, 26, 28, 29,
  106. #           30, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45, 47, 47, 48, 50, 51, 52,
  107. #           54, 55, 56, 58, 59, 61, 62, 64, 65, 67, 68, 69, 71, 73, 74, 75, 76,
  108. #           77, 79, 80, 81, 82, 84, 86, 87, 88, 90, 91, 92, 94, 95, 96, 98, 100,
  109. #           101, 102, 104, 105, 107, 110, 111, 112, 114, 116, 117, 118, 120,
  110. #           121, 121, 124, 126, 127, 128, 129, 131, 132, 134, 136, 139, 140,
  111. #           142, 143, 145, 148],
  112. #       This would be the growth for actor 5 and he or she would start with 5
  113. #      luck at level 1 and would have the set amount at each level (so 6 at
  114. #      level 2, 8 at level 3, 9 at level 4, etc...)
  115.   0 => "4 * level / 3",
  116.   2 => "4 + (level / 4)",
  117.   8 => [5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 22, 23, 25, 26, 28, 29, 30,
  118.         32, 33, 35, 36, 38, 39, 41, 42, 44, 45, 47, 47, 48, 50, 51, 52, 54, 55,
  119.         56, 58, 59, 61, 62, 64, 65, 67, 68, 69, 71, 73, 74, 75, 76, 77, 79, 80,
  120.         81, 82, 84, 86, 87, 88, 90, 91, 92, 94, 95, 96, 98, 100, 101, 102, 104,
  121.         105, 107, 110, 111, 112, 114, 116, 117, 118, 120, 121, 121, 124, 126,
  122.         127, 128, 129, 131, 132, 134, 136, 139, 140, 142, 143, 145, 148],
  123. } # <- DO not touch
  124. MALS_LUCK_ICON = 103    # This is icon for Luck if you are using YEM scripts
  125. #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  126. #    END EDITABLE REGION
  127. #//////////////////////////////////////////////////////////////////////////////
  128. MALS_LUCK_GROWTH.default = MALS_LUCK_GROWTH[0] # <- Do not touch
  129.  
  130. $imported = {} unless $imported
  131. $imported["LuckStat"] = true
  132.  
  133. #==============================================================================
  134. # *** RPG
  135. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  136. #  Summary of Changes:
  137. #    modified classes - BaseItem; State; Actor; Enemy
  138. #==============================================================================
  139.  
  140. module RPG
  141.  
  142. #============================================================================
  143. # ** BaseItem
  144. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  145. #  Summary of Changes:
  146. #    new method - luck; luck_rate
  147. #============================================================================
  148.  
  149. class BaseItem
  150.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  151.   # * Luck
  152.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  153.   def luck
  154.     @luck = (self.note[/\\LUCK\[(-?\d+)\]/i] != nil ? $1.to_i : 0) if !@luck
  155.     return @luck
  156.   end
  157.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158.   # * Luck Rate
  159.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  160.   def luck_rate
  161.     @luck_rate = (self.note[/\\LUCK\[(-?\d+)%\]/i] != nil ? $1.to_f / 100.0 : 0) if !@luck_rate
  162.     return @luck_rate
  163.   end
  164.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  165.   # * Compatibility with Note Editor
  166.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  167.   if self.method_defined? (:ma_reset_note_values)
  168.     alias mlg_luk_rstnotes_4rf2 ma_reset_note_values
  169.     def ma_reset_note_values (*args)
  170.       mlg_luk_rstnotes_4rf2 (*args)
  171.       @luck = nil
  172.       @luck_rate = nil
  173.     end
  174.   end
  175. end
  176.  
  177. #============================================================================
  178. # ** State
  179. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  180. #  Summary of Changes:
  181. #    new method - luck; luck_rate
  182. #    aliased method - auto_release_prob
  183. #============================================================================
  184.  
  185. class State
  186.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  187.   # * Luck
  188.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  189.   def luck
  190.     @luck = (self.note[/\\LUCK\[(-?\d+)\]/i] != nil ? $1.to_i : 0) if !@luck
  191.     return @luck
  192.   end
  193.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  194.   # * Luck Rate
  195.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  196.   def luck_rate
  197.     @luck_rate = (self.note[/\\LUCK\[(-?\d+)%\]/i] != nil ? $1.to_f / 100.0 : 0) if !@luck_rate
  198.     return @luck_rate
  199.   end
  200.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  201.   # * Positive State?
  202.   #    This allows you to specify some states as positive, thus meaning luck
  203.   #   will favourably influence its application instead of unfavourably
  204.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  205.   def positive_state?
  206.     @positivity = self.note[/\\POSITIVE/i] != nil if @positivity == nil
  207.     return @positivity
  208.   end
  209.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  210.   # * Auto Release Probability
  211.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  212.   alias ma_lk_autorel_5tc7 auto_release_prob unless self.method_defined? (:ma_lk_autorel_5tc7)
  213.   def auto_release_prob (*args)
  214.     prob = ma_lk_autorel_5tc7 (*args)
  215.     if $game_temp && positive_state?
  216.       prob = 2*prob - $game_temp.luck_prob (prob)
  217.     else
  218.       prob = $game_temp.luck_prob (prob)
  219.     end
  220.     return prob
  221.   end
  222.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  223.   # * Compatibility with Note Editor
  224.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  225.   if self.method_defined? (:ma_reset_note_values)
  226.     alias mlg_luk_rstnotes_4rf2 ma_reset_note_values
  227.     def ma_reset_note_values (*args)
  228.       mlg_luk_rstnotes_4rf2 (*args)
  229.       @luck = nil
  230.       @luck_rate = nil
  231.       @positivity = nil
  232.     end
  233.   end
  234. end
  235.  
  236. #==============================================================================
  237. # ** Actor
  238. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  239. #  Summary of Changes:
  240. #    new method - luck
  241. #==============================================================================
  242.  
  243. class Actor
  244.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  245.   # * Luck
  246.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  247.   def luck (level)
  248.     @luck_base = [] if !@luck_base
  249.     if @luck_base[level] == nil
  250.       growth = MALS_LUCK_GROWTH[self.id]
  251.       if growth.is_a? (Array)
  252.         @luck_base[level] = growth[[level - 1, growth.size - 1].min]
  253.       else
  254.         eval ("@luck_base[level] = #{growth}")
  255.       end
  256.     end
  257.     return @luck_base[level]
  258.   end
  259. end
  260.  
  261. #==============================================================================
  262. # ** Enemy
  263. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  264. #  Summary of Changes:
  265. #    new method - luck
  266. #    modified class - DropItem
  267. #==============================================================================
  268.  
  269. class Enemy
  270.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  271.   # * Luck
  272.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  273.   def luck
  274.     @luck = (self.note[/\\LUCK\[(-?\d+)\]/i] != nil ? $1.to_i : 0) if @luck == nil
  275.     return @luck
  276.   end
  277.  
  278.   #==========================================================================
  279.   # ** DropItem
  280.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  281.   #  Summary of Changes:
  282.   #    aliased method - denominator
  283.   #==========================================================================
  284.  
  285.   class DropItem
  286.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  287.     # * Denominator
  288.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  289.     alias mlgb_luk_denmn_4rt2 denominator unless self.method_defined? (:mlgb_luk_denmn_4rt2)
  290.     def denominator (*args)
  291.       denom = mlgb_luk_denmn_4rt2 (*args) # Run Original Method
  292.       percent = $game_temp.luck_prob (100 / denom)
  293.       return (100.0 / percent).round
  294.     end
  295.   end
  296.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  297.   # * Compatibility with Note Editor
  298.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  299.   if self.method_defined? (:ma_reset_note_values)
  300.     alias mlg_luk_rstnotes_4rf2 ma_reset_note_values
  301.     def ma_reset_note_values (*args)
  302.       mlg_luk_rstnotes_4rf2 (*args)
  303.       @luck_base = []
  304.     end
  305.   end
  306. end
  307.  
  308. #==============================================================================
  309. #  TDS Weapon Unleash Compatibility
  310. #==============================================================================
  311. class Weapon
  312.   if self.method_defined? (:unleash_info)
  313.     alias ma_luk_com_wpnunls_8ib3 unleash_info
  314.     def unleash_info (*args)
  315.       array = ma_luk_com_wpnunls_8ib3 (*args)
  316.       array[1] = $game_temp.luck_prob (array[1]) if array && $game_temp
  317.       return array
  318.     end
  319.   end
  320. end
  321.  
  322. end
  323.  
  324. #==============================================================================
  325. # *** Vocab
  326. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  327. #  Summary of Changes:
  328. #    new method - luck
  329. #==============================================================================
  330.  
  331. module Vocab
  332.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  333.   # * Luck
  334.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  335.   def self.luck
  336.     return MALS_VOCAB_LUCK
  337.   end
  338. end
  339.  
  340. #==============================================================================
  341. # ** Game_Temp
  342. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  343. #  Summary of Changes:
  344. #    new accessor - luck_mod
  345. #    aliased method - initialize
  346. #==============================================================================
  347.  
  348. class Game_Temp
  349.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  350.   # * Public Instance Variables
  351.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  352.   attr_accessor :luck_mod
  353.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  354.   # * Object Initialization
  355.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  356.   alias mrgb_lc_iniz_1wd9 initialize
  357.   def initialize (*args)
  358.     mrgb_lc_iniz_1wd9 (*args) # Run Original Method
  359.     @luck_mod = 0
  360.   end
  361.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  362.   # * Luck Probability
  363.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  364.   def luck_prob (prob, luck = @luck_mod)
  365.     return prob if prob == 100 || luck <= 0
  366.     t = luck / 100
  367.     t += 1 if rand (100) < (luck % 100)
  368.     return t == 0 ? prob : ((1.0 - (((100 - prob).to_f / 100.0)**(t + 1))) * 100).to_i
  369.   end
  370. end
  371.  
  372. #==============================================================================
  373. # ** Game_Battler
  374. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  375. #  Summary of Changes:
  376. #    aliased methods - clear_extra_values; item_growth_effect; item_test;
  377. #      remove_states_auto; make_attack_damage_value; calc_hit; calc_eva
  378. #    new method - luck; luck=
  379. #==============================================================================
  380.  
  381. class Game_Battler
  382.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  383.   # * Object Initialization
  384.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  385.   alias malg_luck_clrexvals_5yq1 clear_extra_values
  386.   def clear_extra_values (*args)
  387.     malg_luck_clrexvals_5yq1 (*args) # Run Original Method
  388.     @luck_plus = 0
  389.   end
  390.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  391.   # * Item Growth Effect Application
  392.   #     user : Item user
  393.   #     item : item
  394.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  395.   alias modrna_itmgrowth_eff_6yh4 item_growth_effect
  396.   def item_growth_effect(user, item, *args)
  397.     modrna_itmgrowth_eff_6yh4 (user, item, *args)
  398.     @luck_plus += item.luck + (item.luck_rate*self.luck)
  399.   end
  400.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  401.   # * Item Test
  402.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403.   alias mdlg_luc_itmtst_5rx2 item_test
  404.   def item_test(user, item, *args)
  405.     return true if item.luck != 0 || item.luck_rate != 0
  406.     return mdlg_luc_itmtst_5rx2 (user, item, *args)
  407.   end
  408.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  409.   # * Auto Remove States
  410.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  411.   alias odagb_lck_rmvautostt_6jn2 remove_states_auto
  412.   def remove_states_auto (*args)
  413.     $game_temp.luck_mod = self.luck
  414.     odagb_lck_rmvautostt_6jn2 (*args) # Auto Remove States
  415.     $game_temp.luck_mod = 0
  416.   end
  417.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  418.   # * Make Attack Damage Value
  419.   #    do luck_mod here instead of cri so as not to corrupt the general stat
  420.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  421.   alias mlg_luck_dmg_atk_9uc4 make_attack_damage_value
  422.   def make_attack_damage_value (attacker, *args)
  423.     $game_temp.luck_mod = attacker.luck
  424.     mlg_luck_dmg_atk_9uc4 (attacker, *args) # Run Original Method
  425.     $game_temp.luck_mod = 0
  426.   end
  427.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  428.   # * Calculation of Final Hit Ratio
  429.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  430.   alias maba_luk_htclc_7uz3 calc_hit
  431.   def calc_hit (user, *args)
  432.     hit = maba_luk_htclc_7uz3 (user, *args)
  433.     return $game_temp.luck_prob (hit, user.luck)
  434.   end
  435.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  436.   # * Calculate Final Evasion Rate
  437.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  438.   alias malgbr_lck_clceva_3da7 calc_eva
  439.   def calc_eva(user, *args)
  440.     eva = malgbr_lck_clceva_3da7 (user, *args)
  441.     return $game_temp.luck_prob (eva, self.luck)
  442.   end
  443.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  444.   # * Luck
  445.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  446.   def luck
  447.     n = [[base_luck + @luck_plus, 1].max, 999].min
  448.     floats = 1.0
  449.     for state in states
  450.       floats += state.luck_rate
  451.       n += state.luck_rate
  452.     end
  453.     n *= floats
  454.     n = [[Integer(n), 1].max, 999].min
  455.     return n
  456.   end
  457.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  458.   # * Set Luck
  459.   #    new_luck : the new value of luck
  460.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  461.   def luck= (new_luck)
  462.     @luck_plus += new_luck - self.luck
  463.     @luck_plus = [[@luck_plus, -999].max, 999].min
  464.   end
  465.   #==========================================================================
  466.   #  TDS Weapon Unleash Compatibility
  467.   #==========================================================================
  468.   if self.method_defined? (:weapon_unleash?)
  469.     alias ma_lk_cmp_tdswu_5th1 weapon_unleash?
  470.     def weapon_unleash? (*args)
  471.       $game_temp.luck_mod = luck
  472.       v = ma_lk_cmp_tdswu_5th1 (*args)
  473.       $game_temp.luck_mod = 0
  474.       return v
  475.     end
  476.   end
  477. end
  478.  
  479. #==============================================================================
  480. # ** Game_Actor
  481. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  482. #  Summary of Changes:
  483. #    aliased method - state_probability; cri
  484. #    new method - base_luck
  485. #==============================================================================
  486.  
  487. class Game_Actor
  488.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  489.   # * Get Basic Luck
  490.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  491.   def base_luck
  492.     n = actor.luck (@level)
  493.     floats = 1.0
  494.     for equip in equips.compact
  495.       floats += equip.luck_rate
  496.       n += equip.luck
  497.     end
  498.     n = (n*floats).to_i
  499.     return n
  500.   end
  501.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  502.   # * State Probability
  503.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  504.   alias mag_luck_probstate_8id2 state_probability
  505.   def state_probability (state_id, *args)
  506.     default = mag_luck_probstate_8id2 (state_id, *args)
  507.     $game_temp.luck_mod = luck
  508.     if $data_states[state_id].positive_state?
  509.       return $game_temp.luck_prob (default)
  510.     else
  511.       return 2*default - ($game_temp.luck_prob (default))
  512.     end
  513.     $game_temp.luck_mod = 0
  514.   end
  515.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  516.   # * Critical
  517.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  518.   alias malg_luk_cri_7uk9 cri
  519.   def cri (*args)
  520.     return $game_temp.luck_prob (malg_luk_cri_7uk9 (*args))
  521.   end
  522. end
  523.  
  524. #==============================================================================
  525. # ** Game_Enemy
  526. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  527. #  Summary of Changes:
  528. #    aliased method - state_probability
  529. #    new method - base_luck
  530. #==============================================================================
  531.  
  532. class Game_Enemy
  533.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  534.   # * Get Basic Luck
  535.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  536.   def base_luck
  537.     return enemy.luck
  538.   end
  539.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  540.   # * State Probability
  541.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  542.   alias mag_luck_stateprob_4tg2 state_probability
  543.   def state_probability (state_id, *args)
  544.     default = mag_luck_stateprob_4tg2 (state_id, *args)
  545.     $game_temp.luck_mod = luck
  546.     if $data_states[state_id].positive_state?
  547.       return $game_temp.luck_prob (default)
  548.     else
  549.       return 2*default - ($game_temp.luck_prob (default))
  550.     end
  551.     $game_temp.luck_mod = 0
  552.   end
  553.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  554.   # * Critical
  555.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  556.   alias malg_lck_crit_2wq1 cri
  557.   def cri (*args)
  558.     return $game_temp.luck_prob (malg_lck_crit_2wq1 (*args))
  559.   end
  560. end
  561.  
  562. #==============================================================================
  563. # ** Game_Unit
  564. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  565. #  Summary of Changes:
  566. #    new method - luck_average
  567. #==============================================================================
  568.  
  569. class Game_Unit
  570.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  571.   # * Average Luck
  572.   #    This takes the mean of the party member's luck for gold & item drop %
  573.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  574.   def luck_average
  575.     luck = 0
  576.     existing_members.each { |actor| luck += actor.luck }
  577.     return (luck / [1, existing_members.size].max)
  578.   end
  579. end
  580.  
  581. #==============================================================================
  582. # ** Game Troop
  583. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  584. #  Summary of Changes:
  585. #    aliased methods - gold_total; make_drop_items
  586. #==============================================================================
  587.  
  588. class Game_Troop
  589.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  590.   # * Gold Total
  591.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  592.   alias mrgba_luk_glddrop_7uj1 gold_total
  593.   def gold_total (*args)
  594.     total = mrgba_luk_glddrop_7uj1 (*args)
  595.     total += rand (1 + (total * ($game_party.luck_average / 100.0)).to_i)
  596.     return total
  597.   end
  598.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  599.   # * Make Drop Items
  600.   #    luck_mod done here to avoid corrupting denominator
  601.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  602.   alias mgba_luk_dropitms_8fv2 make_drop_items
  603.   def make_drop_items (*args)
  604.     $game_temp.luck_mod = $game_party.luck_average
  605.     v = mgba_luk_dropitms_8fv2 (*args)
  606.     $game_temp.luck_mod = 0
  607.     return v
  608.   end
  609. end
  610.  
  611. #==============================================================================
  612. # ** Window_Status
  613. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  614. #  Summary of Changes:
  615. #    aliased method - draw_parameters
  616. #==============================================================================
  617. if MALS_STATUS_SHOW
  618.   class Window_Status
  619.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  620.     # * Draw Parameters
  621.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  622.     alias ma_luk_drwparams_2fg4 draw_parameters
  623.     def draw_parameters (x, y, *args)
  624.       ma_luk_drwparams_2fg4 (x, y, *args)
  625.       x = MALS_STATUS_X if MALS_STATUS_X != -1
  626.       y = (MALS_STATUS_Y != -1 ? MALS_STATUS_Y : y + WLH*4 + MALS_STATUS_Y.abs - 1)
  627.       self.contents.font.color = system_color
  628.       self.contents.draw_text(x, y, 120, WLH, Vocab::luck)
  629.       self.contents.font.color = normal_color
  630.       self.contents.draw_text(x + 120, y, 36, WLH, @actor.luck, 2)
  631.     end
  632.   end
  633. end
  634.  
  635. if MALS_EQUIP_SHOW
  636.   #============================================================================
  637.   # ** Window_EquipStatus
  638.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  639.   #  Summary of Changes:
  640.   #    modified_constant - WLH
  641.   #    aliased method - refresh
  642.   #    new method - set_luck
  643.   #============================================================================
  644.   class Window_EquipStatus
  645.     WLH = 20
  646.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  647.     # * Set Luck
  648.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  649.     def set_luck (new_luck)
  650.       if @new_luck != new_luck
  651.         @new_luck = new_luck
  652.         refresh
  653.       end
  654.     end
  655.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  656.     # * Refresh
  657.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  658.     alias mdrn_luk_eqpref_7us6 refresh
  659.     def refresh (*args)
  660.       if self.contents.height < 120
  661.         self.height = 152
  662.         create_contents
  663.       end
  664.       mdrn_luk_eqpref_7us6 (*args)
  665.       self.contents.font.color = system_color
  666.       self.contents.draw_text(4, WLH*5, 80, WLH, Vocab::luck)
  667.       self.contents.font.color = normal_color
  668.       self.contents.draw_text(90, WLH*5, 30, WLH, @actor.luck, 2)
  669.       self.contents.font.color = system_color
  670.       self.contents.draw_text(122, WLH*5, 20, WLH, ">", 1)
  671.       if @new_luck != nil
  672.         self.contents.font.color = new_parameter_color(@actor.luck, @new_luck)
  673.         self.contents.draw_text(142, WLH*5, 30, WLH, @new_luck, 2)
  674.       end
  675.     end
  676.   end
  677.  
  678.   #============================================================================
  679.   # ** Scene Equip
  680.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  681.   #  Summary of Changes:
  682.   #    aliased method
  683.   #============================================================================
  684.  
  685.   class Scene_Equip
  686.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  687.     # * Update Status Window
  688.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  689.     alias malg_luck_updstatwin_6yh3 update_status_window
  690.     def update_status_window (*args)
  691.       if @equip_window.active
  692.         @status_window.set_luck (nil)
  693.       elsif @item_window.active
  694.         temp_actor = @actor.clone
  695.         temp_actor.change_equip(@equip_window.index, @item_window.item, true)
  696.         @status_window.set_luck (temp_actor.luck)
  697.       end
  698.       malg_luck_updstatwin_6yh3 (*args)
  699.     end
  700.   end
  701. end
  702.  
  703. #==============================================================================
  704. # YEM COMPATIBILITY
  705. #==============================================================================
  706.  
  707. #  Status Menu Melody
  708. if $imported["StatusMenuMelody"] && MALS_STATUS_SHOW
  709.   #==========================================================================
  710.   # ** Window Status General
  711.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  712.   #  Summary of Changes:
  713.   #    aliased method - draw_parameters
  714.   #==========================================================================
  715.   class Window_Status_General
  716.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  717.     # * Draw Parameters
  718.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  719.     alias mlgb_luk_drwparams_6yv2 draw_parameters
  720.     def draw_parameters (x, y, *args)
  721.       mlgb_luk_drwparams_6yv2 (x, y, *args)
  722.       x += 24
  723.       x = MALS_STATUS_X if MALS_STATUS_X != -1
  724.       y = (MALS_STATUS_Y != -1 ? MALS_STATUS_Y : y + (WLH*(2 + YEM::STATUS::SHOWN_STATS.size)) + MALS_STATUS_Y.abs - 1)
  725.       draw_icon(MALS_LUCK_ICON, x, y)
  726.       self.contents.font.color = system_color
  727.       self.contents.draw_text(x + 24, y, 48, WLH, Vocab::luck)
  728.       self.contents.font.color = normal_color
  729.       self.contents.draw_text(x + 72, y, 84, WLH, @actor.luck, 2)
  730.     end
  731.   end
  732. end
  733. #  Equipment Overhaul
  734. if $imported["EquipmentOverhaul"] && MALS_EQUIP_SHOW
  735.   #==========================================================================
  736.   # ** Window EquipStat
  737.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  738.   #  Summary of Changes:
  739.   #    aliased methods - draw_actor_stats; draw_clone_stats
  740.   #==========================================================================
  741.   class Window_EquipStat
  742.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  743.     # * Draw Actor Stats
  744.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  745.     alias modrn_yemequip_drwactrstats_8uf2 draw_actor_stats
  746.     def draw_actor_stats (*args)
  747.       modrn_yemequip_drwactrstats_8uf2 (*args) # Run Original Method
  748.       dy = WLH*YEM::EQUIP::SHOWN_STATS.size
  749.       draw_icon(MALS_LUCK_ICON, 0, dy)
  750.       self.contents.font.size = YEM::EQUIP::STAT_FONT_SIZE
  751.       self.contents.font.color = system_color
  752.       self.contents.draw_text(24, dy, 60, WLH, Vocab.luck, 0)
  753.       self.contents.font.color = normal_color
  754.       self.contents.draw_text(84, dy, 45, WLH, @actor.luck, 2)
  755.       self.contents.font.color = system_color
  756.       self.contents.font.size = Font.default_size
  757.       self.contents.draw_text(129, dy, 30, WLH, YEM::EQUIP::VOCAB[:arrow], 1)
  758.       if @equip_index == nil or (@equip != nil and !@actor.equippable?(@equip))
  759.         self.contents.font.size = YEM::EQUIP::STAT_FONT_SIZE
  760.         self.contents.font.color = normal_color
  761.         self.contents.draw_text(159, dy, 45, WLH, @actor.luck, 2)
  762.       end
  763.     end
  764.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  765.     # * Draw Clone Stats
  766.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  767.     alias modrn_yemequip_luk_clnst_5tb9 draw_clone_stats
  768.     def draw_clone_stats (*args)
  769.       modrn_yemequip_luk_clnst_5tb9 (*args) # Run Original Method
  770.       dy = WLH*YEM::EQUIP::SHOWN_STATS.size
  771.       if @clone.luck > @actor.luck
  772.         self.contents.font.color = power_up_color
  773.       elsif @clone.luck < @actor.luck
  774.         self.contents.font.color = power_down_color
  775.       else
  776.         self.contents.font.color = normal_color
  777.       end
  778.       self.contents.font.size = YEM::EQUIP::STAT_FONT_SIZE
  779.       self.contents.draw_text(159, dy, 45, WLH, @clone.luck, 2)
  780.     end
  781.   end
  782. end
RAW Paste Data