Advertisement
roninator2

Troyz States hit count remove - addon shield state

Dec 5th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.23 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Shield State Count Hit fix   ║  Version: 1.02     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:  Patch                    ║   Date Created     ║
  6. # ║      Allow hit to not do damage     ╠════════════════════╣
  7. # ║      when successful.               ║    05 Jan 2021     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Requires: TroyZ - States Hit Count Removal               ║
  11. # ╚══════════════════════════════════════════════════════════╝
  12. # ╔══════════════════════════════════════════════════════════╗
  13. # ║ Instructions:                                            ║
  14. # ║                                                          ║
  15. # ║ Original script allowed a state to be removed when hit,  ║
  16. # ║ but if the state is a shield to block all damage         ║
  17. # ║ then the player still took damage, this fixes it.        ║
  18. # ║                                                          ║
  19. # ║ Add Shield States below:                                 ║
  20. # ║ Each state number added will protect from type damage    ║
  21. # ║ Can be a single number [28], or multiple [4, 18, 28]     ║
  22. # ║                                                          ║
  23. # ║ Each one has it's specific hit type                      ║
  24. # ║ Shield_State = Physical hit type                         ║
  25. # ║ Mind_Shield = Magical hit type                           ║
  26. # ║ Certain_Shield = Certain hit type                        ║
  27. # ╚══════════════════════════════════════════════════════════╝
  28. # ╔══════════════════════════════════════════════════════════╗
  29. # ║ Updates:                                                 ║
  30. # ║ 1.00 - 05 Jan 2021 - Initial publish                     ║
  31. # ║ 1.01 - 06 Jan 2021 - Seperated damage to hit type        ║
  32. # ║ 1.02 - 06 Jan 2021 - Created percentage damage option    ║
  33. # ╚══════════════════════════════════════════════════════════╝
  34. # ╔══════════════════════════════════════════════════════════╗
  35. # ║ Terms of use:                                            ║
  36. # ║ Follow the Original Authors terms                        ║
  37. # ╚══════════════════════════════════════════════════════════╝
  38. module R2_State_Shield_Remove_On_Hit
  39.     # states that give 100% protection from damage
  40.   Physical_Shield = [1, 28]
  41.   # Physical hit type protection
  42.   Mind_Shield = [13, 29]
  43.   # Magic hit type protection
  44.   Certain_Shield = [4, 30]
  45.   # Certain hit type protection
  46.    
  47.     # states that give percentage protection
  48.   Half_Physical = [2, 33]
  49.   # Physical hit type protection
  50.   Half_Mind = [14, 32]
  51.   # Magic hit type protection
  52.   Half_Certain = [5, 31]
  53.   # Certain hit type protection
  54.    
  55.     # Percentage values for half states 50 = 50%
  56.   Physical_Rate = 50
  57.   # Physical hit type protection percentage value
  58.   Mind_Rate = 70
  59.   # Magic hit type protection percentage value
  60.   Certain_Rate = 30
  61.   # Certain hit type protection percentage value
  62.    
  63. end
  64.  
  65. class Game_Battler < Game_BattlerBase
  66.   def make_damage_value(user, item)
  67.     value = item.damage.eval(user, self, $game_variables)
  68.     value *= item_element_rate(user, item)
  69.     value *= pdr if item.physical?
  70.     value *= mdr if item.magical?
  71.     value *= rec if item.damage.recover?
  72.     value = apply_critical(value) if @result.critical
  73.     value = apply_variance(value, item.damage.variance)
  74.     value = apply_guard(value)
  75.     R2_State_Shield_Remove_On_Hit::Half_Physical.each { |st|
  76.       if item.physical? && @states.include?(st)
  77.         value = ((value * R2_State_Shield_Remove_On_Hit::Physical_Rate) / 100).to_i
  78.       end
  79.     }
  80.     R2_State_Shield_Remove_On_Hit::Half_Certain.each { |st|
  81.       if item.certain? && @states.include?(st)
  82.         value = ((value * R2_State_Shield_Remove_On_Hit::Certain_Rate) / 100).to_i
  83.       end
  84.     }
  85.     R2_State_Shield_Remove_On_Hit::Half_Mind.each { |st|
  86.       if item.magical? && @states.include?(st)
  87.         value = ((value * R2_State_Shield_Remove_On_Hit::Mind_Rate) / 100).to_i
  88.       end
  89.     }
  90.     R2_State_Shield_Remove_On_Hit::Physical_Shield.each { |st|
  91.       if item.physical? && @states.include?(st)
  92.         value = 0
  93.         update_states_hit_count
  94.         remove_states_by_hit_count
  95.       end
  96.     }
  97.     R2_State_Shield_Remove_On_Hit::Certain_Shield.each { |st|
  98.       if item.certain? && @states.include?(st)
  99.         value = 0
  100.         update_states_hit_count
  101.         remove_states_by_hit_count
  102.       end
  103.     }
  104.     R2_State_Shield_Remove_On_Hit::Mind_Shield.each { |st|
  105.       if item.magical? && @states.include?(st)
  106.         value = 0
  107.         update_states_hit_count
  108.         remove_states_by_hit_count
  109.       end
  110.     }
  111.     @result.make_damage(value.to_i, item)
  112.   end
  113. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement