noelburgundy27

Tactics Ogre MP Regeneration Battle v1.0a

Feb 23rd, 2015
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.46 KB | None | 0 0
  1. =begin
  2.  Tactics Ogre MP Battle v 1.1a
  3.  Script by California Macky a.k.a. Neil a.k.a. mackintosh a.k.a. noelburgundy27
  4.  
  5. Description:
  6. Replicates Tactics Ogre (Let Us Cling Together) MP and TP  Mechanics,
  7. where you start out with zero MP and/or TP, which you slowly gain per turn.
  8. That means no one can immediately cast their spells and must wait it out or
  9. strategize. Ideal for turn-based battles.
  10.  
  11. This version is still in alpha and may need tweaks. If you find any, PM me
  12. in the forums or leave a comment in my wordpress. If you have formula ideas,
  13. please let me know, as well.
  14. (http://calimackrpg.wordpress.com)
  15.  
  16. Instructions:
  17. Put this below your battle scripts and above Main.
  18.  
  19. ================================================================================
  20. CHANGELOG
  21.   1.0a - Completed script and fixed a few bugs with default system
  22.   1.1a - Added feature to enable/disable MRG and TRG for all battlers
  23.  
  24. ================================================================================
  25.  
  26.  
  27.  
  28. TERMS OF USE (DO NOT EDIT)
  29. For both commercial and non-commercial projects, please credit me and hand me
  30. a copy of the game. Email me at [ [email protected] ] regarding
  31. due process.
  32.  
  33. Donations are appreciated. ( http://bit.ly/feed-calimack )
  34.  
  35. =end
  36.  
  37. module MP_TP_GEN
  38.   #If true, MP starts at 0 and slowly regens by Base_MPGen and actor MRG
  39.   Active_MPGen = true
  40.  
  41.   #If true, TP starts at 0 and slowly regens by Base_TPGen and actor TRG and TCR
  42.   #TP resets to 0 every time battle starts.
  43.   Active_TPGen = true
  44.  
  45.   #MRG and TRG automatically restores MP and TP in the default system.
  46.   #Use these to disable or enable
  47.   Active_Default_MRG = true
  48.   Active_Default_TRG = true
  49.  
  50.   #Charge TP when receiving damage. Input true or false
  51.   DMG_TPGen = false
  52.  
  53.   #TP is preserved after battle. Does not apply when Active_TPGen is ON.
  54.   PRESERVE_TP = true
  55.  
  56.   #This variable sets Base MP_Regen per turn. Use number values only.
  57.   #Decimals are rounded off.
  58.   Base_MPGen = 5
  59.  
  60.   #This variable sets Base TP_Regen per turn. Use number values only.
  61.   #Decimals are rounded off.
  62.   Base_TPGen = 5
  63.  
  64.   #-----------------------------------------------------------------------------
  65.   # The Formula for MP regen each turn end. Change as desired.
  66.   def mp_regen(battler)
  67.     sum  = (battler.mmp) / 25 * (1.0 + battler.mrg)
  68.     sum = Base_MPGen if (sum < Base_MPGen)
  69.     battler.mp += sum.round.to_i
  70.   end
  71.  
  72.   #-----------------------------------------------------------------------------
  73.   # The Formula for TP regen each second. Change as desired.
  74.   def tp_regen(battler)
  75.     sum  = (battler.max_tp) / 25 * (battler.tcr) * (1.0 + battler.trg)
  76.     sum = Base_TPGen if (sum < Base_TPGen)
  77.     battler.tp += sum.round.to_i
  78.   end
  79.  
  80. end
  81.  
  82.  
  83.  
  84. #===============================================================================
  85. #                                    WARNING
  86. #                      Customization ends here. Proceed at your
  87. #                                own risk, people.
  88. #
  89. #===============================================================================
  90.  
  91. #===============================================================================
  92. #
  93. # *BattleManager
  94. #
  95. #===============================================================================
  96. module BattleManager
  97.   def self.nuke_mp
  98.     $game_party.members.each do |actor|
  99.       actor.mp = 0
  100.     end
  101.     $game_troop.members.each do |actor|
  102.       actor.mp = 0
  103.     end
  104.   end
  105.  
  106.   def self.nuke_tp
  107.     $game_party.members.each do |actor|
  108.       actor.tp = 0
  109.     end
  110.     $game_troop.members.each do |actor|
  111.       actor.tp = 0
  112.     end
  113.   end
  114.  
  115. end
  116.  
  117. #===============================================================================
  118. #
  119. # *Game_Battler
  120. #
  121. #===============================================================================
  122. class Game_Battler < Game_BattlerBase
  123.  
  124.   include MP_TP_GEN
  125.  
  126.   #--------------------------------------------------------------------------
  127.   # * Initialize TP
  128.   #--------------------------------------------------------------------------
  129.   alias neil_normal_init_tp init_tp
  130.   def init_tp
  131.     neil_normal_init_tp
  132.   end
  133.  
  134.   #--------------------------------------------------------------------------
  135.   # * Regenerate All
  136.   #--------------------------------------------------------------------------
  137.   def regenerate_all
  138.     if alive?
  139.       regenerate_hp
  140.       regenerate_mp unless !Active_Default_MRG
  141.       regenerate_tp unless !Active_Default_TRG
  142.     end
  143.   end
  144.  
  145.   def charge_tp_by_damage(damage_rate)
  146.     self.tp += 50 * damage_rate * tcr if DMG_TPGen
  147.   end
  148.  
  149.   def preserve_tp?
  150.     return PRESERVE_TP
  151.   end
  152.  
  153.   #--------------------------------------------------------------------------
  154.   # * Processing at Start of Battle
  155.   #--------------------------------------------------------------------------
  156.   def on_battle_start
  157.     neil_normal_init_tp unless preserve_tp?
  158.     self.tp = 0 if Active_TPGen
  159.     self.mp = 0 if Active_MPGen
  160.   end
  161.  
  162.   #--------------------------------------------------------------------------
  163.   # * Processing at End of Action
  164.   #--------------------------------------------------------------------------
  165.   alias neil_on_action_end  on_action_end
  166.   def on_action_end
  167.     neil_on_action_end
  168.   end
  169.  
  170.   #--------------------------------------------------------------------------
  171.   # * Processing at End of Turn
  172.   #--------------------------------------------------------------------------
  173.   alias neil_on_turn_end    on_turn_end
  174.   def on_turn_end
  175.     neil_on_turn_end
  176.   end
  177.  
  178. end
  179.  
  180. #===============================================================================
  181. #
  182. # *Scene_Battle
  183. #
  184. #===============================================================================
  185. class Scene_Battle < Scene_Base
  186.  
  187.   include MP_TP_GEN
  188.  
  189.   alias neil_normal_battle_start    battle_start
  190.   def battle_start
  191.     neil_normal_battle_start
  192.     BattleManager.nuke_mp if Active_MPGen
  193.     BattleManager.nuke_tp if Active_TPGen
  194.   end
  195.  
  196.   def mmp_total
  197.     sum = 0.0
  198.     $game_party.battle_members.each do |actor|
  199.       sum += actor.mmp
  200.     end
  201.     $game_troop.members.each do |actor|
  202.       sum += actor.mmp
  203.     end
  204.     return sum
  205.   end
  206.  
  207.   alias neil_normal_turn_end turn_end
  208.   def turn_end
  209.     all_battle_members.each do |battler|
  210.       if !(battler.hp == 0)
  211.         mp_regen(battler) if Active_MPGen
  212.         tp_regen(battler) if Active_TPGen
  213.       end
  214.     end
  215.     neil_normal_turn_end
  216.   end
  217.  
  218. end #CLASS Scene_Battle END
Advertisement
Add Comment
Please, Sign In to add comment