Advertisement
Ventwig

VTS-Wound Damage

Jul 15th, 2014
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.24 KB | None | 0 0
  1. #============================================================================
  2. #VTS Wound Damage
  3. #By Ventwig
  4. #Version 1.01 - Jul 17 2014
  5. #For RPGMaker VX Ace
  6. #=============================================================================
  7. # Description:
  8. # Attacks can deal "wound damage" on top of regular HP damage.
  9. # Wound damage damages the target's Max HP, preventing them from fully
  10. # recovering their HP, just like in Final Fantasy XIII-2.
  11. # Certain items and skills assigned by the user can recover wounds.
  12. #===============================================================================
  13. # Instructions: Put in materials, above main.
  14. # Customization features below, as well as notetags
  15. #==============================================================================
  16. # Please give credit to Ventwig if you would like to use one of my scripts!
  17. # Use it commericial or non-commercial, and feel free to tell me if you're using
  18. # it commercially!
  19. # You may edit my scripts, just don't claim as your own!
  20. #===============================================================================
  21.  
  22. #===============================================================================
  23. #Notetags
  24. #===============================================================================
  25. # All notetags go inside the skill notebox
  26. #
  27. # <wound_rate x>
  28. #================
  29. # This determines what percentage of HP damage will deal wound damage.
  30. # If an attack were to deal 500 damage, and it had a wound rate of 50,
  31. # then the attack will deal 500 damage, and the target's Max HP will be lowered
  32. # by 250.
  33. # To heal wounds, use the same tag except on a healing skill.
  34. # If an actor were to heal 100 HP, and the wound rate is 200, then they will
  35. # recover 100 HP and 200MHP up to the initial limit.
  36. # Negative wound rates DO work. Use these to heal wounds while damaging,
  37. # or inflict them through healing
  38. #
  39. # <wound_only>
  40. #================
  41. # Use this tag if you want the attack to only affect wound hp.
  42. # The damage calculations are still done up in the formula box.
  43. # wound_rate is ignored
  44. #
  45. #=============================
  46. # PLEASE NOTE:
  47. # Wounds are only calculate based on HP damage and HP recovery.
  48. # To deal wounds, the skill has to be set to HP Damage.
  49. # To heal wounds, the skill has to be set to HP Recovery.
  50. #=============================
  51. # DAMAGE FORMULA:
  52. # In the damage formula, mhp (both a.mhp and b.mhp) will refer
  53. # to the target's current max hp. To affect the target's original max hp,
  54. # use omhp, instead. The same is true for percent-based healing.
  55. #
  56. # To refer to an actor's current wound damage, use whp.
  57. #===============================================================================
  58. # CUSTOMIZATION
  59. #===============================================================================
  60. module VTS_WOUNDS
  61.   #The default wound rate of any skill that does not have the <wound_rate x>
  62.   #notetag described above
  63.   DEFAULT_WOUND_RATE = 10
  64.  
  65.   #Set this to true if you want all wounds removed after the battle ends.
  66.   #When wounds are recovered after battle, the lost HP is not.
  67.   #Using this may run into some compatibility errors. Contact me for help.
  68.   RECOVER_AFTER_BATTLE = true
  69.  
  70.   #The colors of the bar indicating current max HP.
  71.   #Color #s set in windowskin
  72.   #Defaults: 10 and 2
  73.   WOUND_COLOR1 = 10
  74.   WOUND_COLOR2 =  2
  75.  
  76.   #The BattleLog text when receiving or recovering wound damage
  77.   #Leavs all %s as they are, but change anything else
  78.   WOUND_DAMAGE_TEXT = "%s took %s Wound Damage!"
  79.   WOUND_HEAL_TEXT = "%s recovered %s Wound Damage!"
  80. end
  81.  
  82. #Customization end
  83.  
  84. module RPG
  85.   class BaseItem
  86.     def wound_rate
  87.       if @wound_rate.nil?
  88.         if @note =~ /<wound_rate (.*)>/i
  89.           @wound_rate= $1.to_i
  90.         else
  91.           @wound_rate = VTS_WOUNDS::DEFAULT_WOUND_RATE
  92.         end
  93.       end
  94.       @wound_rate
  95.     end
  96.     def wound_only
  97.       if @wound_only.nil?
  98.         if @note =~ /<wound_only>/i
  99.           @wound_only = true
  100.         else
  101.           @wound_only = false
  102.         end
  103.       end
  104.       @wound_only
  105.     end
  106.   end
  107. end
  108.  
  109. class Game_ActionResult
  110.   attr_accessor :wound_damage
  111.  
  112.   def hp_damage_text
  113.     if @hp_drain > 0
  114.       fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
  115.       sprintf(fmt, @battler.name, Vocab::hp, @hp_drain)
  116.     elsif @hp_damage > 0
  117.       fmt = @battler.actor? ? Vocab::ActorDamage : Vocab::EnemyDamage
  118.       sprintf(fmt, @battler.name, @hp_damage)
  119.     elsif @hp_damage < 0
  120.       fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
  121.       sprintf(fmt, @battler.name, Vocab::hp, -hp_damage)
  122.     elsif @wound_damage > 0 && @hp_damage == 0
  123.       fmt = VTS_WOUNDS::WOUND_DAMAGE_TEXT
  124.       sprintf(fmt, @battler.name, @wound_damage)
  125.     elsif @wound_damage < 0 && @hp_damage == 0
  126.       fmt = VTS_WOUNDS::WOUND_HEAL_TEXT
  127.       sprintf(fmt, @battler.name, @wound_damage)
  128.     else
  129.       fmt = @battler.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
  130.       sprintf(fmt, @battler.name)
  131.     end
  132.   end
  133.  
  134.   alias wound_make_damage make_damage
  135.   def make_damage(value, item)
  136.     wound_make_damage(value,item)
  137.     if item.wound_only == true
  138.       @wound_damage = @hp_damage
  139.       @hp_damage = 0
  140.     else
  141.       @wound_damage = @hp_damage * item.wound_rate / 100
  142.       @wound_damage = 0 if item.wound_rate == 0 or @hp_damage == 0
  143.     end
  144.   end
  145. end
  146.  
  147. class Game_BattlerBase
  148.   attr_accessor :whp
  149.    
  150.   def mhp;  param(0);   end               # MHP  Maximum Hit Points
  151.   def omhp;  param_base(0);   end               # OMHP  Original Maximum Hit Points
  152.  
  153.   alias wound_initialize initialize
  154.   def initialize
  155.     wound_initialize
  156.     @whp = 0
  157.   end
  158.  
  159.   def mhp_rate
  160.     mhp.to_f / omhp
  161.   end
  162.  
  163.   def hp_rate
  164.     @hp.to_f / omhp
  165.   end
  166. end
  167.  
  168. class Game_Battler < Game_BattlerBase
  169.   alias execute_wound_damage execute_damage
  170.   def execute_damage(user)
  171.     check_wound
  172.     execute_wound_damage(user)
  173.   end
  174.  
  175.   def check_wound
  176.     wound = @result.wound_damage
  177.     wound = [@result.wound_damage,(self.omhp-self.mhp)*-1].max if wound < 0 and @result.hp_damage <= 0
  178.     self.whp += wound
  179.     add_param(0, wound*-1)
  180.   end
  181.  
  182.   alias wound_item_test item_test
  183.   def item_test(user, item)
  184.     return true if item.damage.recover? && item.wound_only && mhp < omhp
  185.     wound_item_test(user, item)
  186.   end
  187.  
  188.   alias wound_battle_end on_battle_end
  189.   def on_battle_end
  190.     clear_param_plus if VTS_WOUNDS::RECOVER_AFTER_BATTLE == true
  191.     wound_battle_end
  192.   end
  193. end
  194.  
  195. class Window_Base < Window
  196.   def draw_actor_hp(actor, x, y, width = 124)
  197.     draw_hp_gauge(x, y, width, actor.hp_rate, actor.mhp_rate, hp_gauge_color1, hp_gauge_color2)
  198.     change_color(system_color)
  199.     draw_text(x, y, 30, line_height, Vocab::hp_a)
  200.     draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
  201.     hp_color(actor), normal_color)
  202.   end
  203.  
  204.   def draw_hp_gauge(x, y, width, rate, rate2, color1, color2)
  205.     fill_w2 = (width * rate2).to_i
  206.     fill_w = (width * rate).to_i
  207.     gauge_y = y + line_height - 8
  208.     contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
  209.     contents.gradient_fill_rect(x, gauge_y, fill_w2, 6, text_color(VTS_WOUNDS::WOUND_COLOR1), text_color(VTS_WOUNDS::WOUND_COLOR2))
  210.     contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
  211.   end
  212. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement