noelburgundy27

TP-Guard System by TheCaliMack

Dec 30th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.24 KB | None | 0 0
  1. =begin
  2. TP-Guard System (Simple TP Shield) v1.0
  3. Script by TheCaliMack and Maliki
  4.  
  5. Description
  6.   Your TP is now your GUARD meter. Build it up to block incoming attacks!
  7.   Max TP is set to be the higher value between your HP and your MP, but you may
  8.   adjust it as you see fit.
  9.  
  10.   This script emulates the Guard mechanic in Dragon Age: Inquisition by replacing
  11.   TP with Guard.
  12.  
  13.   Use the <skip_guard> notetag on skills and items to have them skip GRD.
  14.   calculations.
  15.  
  16.   Also, GainTP really functions as percent now when you make the item effects.
  17.   For example, when you set max_tp to 500 and set the gain tp percentage of
  18.   an item or skill, it will fill up with the said percentage, no longer fixed on
  19.   the 100 TP regular limit.
  20.  
  21.   When it comes to skills, the GainTP% function works by percentage as it would
  22.   in items, but the manual, non-percentage TP input is fixed.
  23.  
  24.  
  25. NOTES ON SCRIPT:
  26.   > TP does not block magical attacks but can be adjusted in the formula below.
  27.   > Individual skills can now ignore Guard with <skip_guard> notetag.
  28.   > DMG_TPGain can manually enable or disable gaining TP from receiving damage.
  29.   > Notes in script allow for customizing damage conversion.
  30.  
  31. Terms of Use:
  32.     > Script is for non-commercial use only.
  33.     > For commercial use, please email script-writer in "[email protected]" for the terms
  34.     > Always include TheCaliMack or California Macky AND Maliki if you decide to use this script in your game.
  35.     > Any variant of the script must have these Terms extended to it. That means you must use these Terms stated above as well as your own.
  36.    
  37. =end
  38.  
  39. module NEILGUARDSYS
  40.   #--------------------------------------------------------------------------
  41.   # DMG_TPGain
  42.   #   Gain TP when receiving damage? Set to 'true' to enable.
  43.   #--------------------------------------------------------------------------
  44.   DMG_TPGain = false
  45.  
  46. end #module END
  47.  
  48.   #--------------------------------------------------------------------------
  49.   # SKIP GUARD NOTETAG
  50.   #   Default notetag is <skip_guard>. Adjust tag as you see fit.
  51.   #--------------------------------------------------------------------------
  52. class RPG::UsableItem < RPG::BaseItem
  53.   def skip_guard?
  54.     if @note =~ /<skip_guard>/i
  55.       return true
  56.     else
  57.       return false
  58.     end
  59.   end
  60. end #RPG::UsableItem END
  61.  
  62.  
  63. class Game_ActionResult
  64. #--------------------------------------------------------------------------
  65. # * Create Damage (overwrites make_damage )
  66. #--------------------------------------------------------------------------
  67.   def make_damage(value, item)
  68.       # value => initial damage
  69.        value2 = value #change this to whatever formula you need
  70.        breaker = value2 - @battler.tp if value2 > @battler.tp
  71.        @critical = false if value == 0
  72.        
  73.       if item.skip_guard? == false
  74.          if (@battler.tp > value2) && item.damage.to_hp? && !item.damage.recover?
  75.               @tp_damage = value2
  76.               @hp_damage = 0
  77.               @battler.tp = [0, (@battler.tp-@tp_damage)].max.to_i
  78.               Sound.play_magic_evasion
  79.           else
  80.               if value2 >= @battler.tp && item.damage.to_hp? && !item.damage.recover?
  81.                 @tp_damage = [@battler.tp, value2].min.to_i
  82.                 @battler.tp -= @tp_damage.to_i
  83.                 @hp_damage = breaker.to_i
  84.               else
  85.                 @hp_damage = value if item.damage.to_hp?            
  86.           end
  87.         end
  88.       else #if skip_guard? is true
  89.         @hp_damage = value if item.damage.to_hp?
  90.       end
  91.        @mp_damage = value if item.damage.to_mp?
  92.        @mp_damage = [@battler.mp, @mp_damage].min
  93.        @hp_drain = @hp_damage if item.damage.drain?
  94.        @mp_drain = @mp_damage if item.damage.drain?
  95.        @hp_drain = [@battler.hp, @hp_drain].min
  96.        @success = true if item.damage.to_hp? || @mp_damage != 0
  97.   end  
  98. end #Game_ActionResult END
  99.  
  100. #--------------------------------------------------------------------------
  101. # * Max TP
  102. #   Modify this to suit your needs. Just change the value returned for max_tp
  103. #--------------------------------------------------------------------------
  104. class Game_BattlerBase  
  105.   def max_tp
  106.     return [param(0), param(1)].max #param(0) is MaxHP. param(1) is MaxMP
  107.   end
  108.  
  109.    def tp_rate
  110.     @tp.to_f / max_tp
  111.   end
  112.  
  113. end #Game_BattlerBase END
  114.  
  115.  
  116. class Game_Battler < Game_BattlerBase
  117.   include NEILGUARDSYS
  118.  
  119.   def item_effect_gain_tp(user, item, effect)
  120.     value    = item_value_recover_tp(user, item, effect)
  121.     self.tp += value
  122.   end
  123.  
  124.   #--------------------------------------------------------------------------
  125.   # * New method: item_value_recover_tp
  126.   #--------------------------------------------------------------------------
  127.   def item_value_recover_tp(user, item, effect)
  128.     value = effect.value1.to_i * self.max_tp
  129.     value = value / 100 if item.is_a?(RPG::Skill)
  130.     value *= user.pha if item.is_a?(RPG::Item)
  131.     value *= user.tcr
  132.     value
  133.   end
  134.  
  135.   def charge_tp_by_damage(damage_rate)
  136.     self.tp += 50 * damage_rate * tcr if DMG_TPGain
  137.   end
  138.  
  139. end #Game_Battler END
  140.  
  141. #==============================================================================
  142. #
  143. # ▼ End of File
  144. #
  145. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment