Advertisement
roninator2

Party TP bar

Dec 11th, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.68 KB | None | 0 0
  1. # ╔═══════════════════════════════════════════════╦════════════════════╗
  2. # ║ Title: TP Bar for Party                       ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                            ║                    ║
  4. # ╠═══════════════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                                     ║   Date Created     ║
  6. # ║   Draws a tp bar for the party                ╠════════════════════╣
  7. # ║                                               ║    16 Mar 2021     ║
  8. # ╚═══════════════════════════════════════════════╩════════════════════╝
  9. # ╔════════════════════════════════════════════════════════════════════╗
  10. # ║ Requires: TheoAllen's Universal TP                                 ║
  11. # ║                                                                    ║
  12. # ╚════════════════════════════════════════════════════════════════════╝
  13. # ╔════════════════════════════════════════════════════════════════════╗
  14. # ║ Brief Description:                                                 ║
  15. # ║   Script provides a tp bar showing the tp for the                  ║
  16. # ║   party. Uses battle member 0's tp                                 ║
  17. # ╚════════════════════════════════════════════════════════════════════╝
  18. # ╔════════════════════════════════════════════════════════════════════╗
  19. # ║ Instructions:                                                      ║
  20. # ║   Configure Settings below                                         ║
  21. # ║                                                                    ║
  22. # ╚════════════════════════════════════════════════════════════════════╝
  23. # ╔════════════════════════════════════════════════════════════════════╗
  24. # ║ Updates:                                                           ║
  25. # ║ 1.00 - 16 Mar 2021 - Script finished                               ║
  26. # ╚════════════════════════════════════════════════════════════════════╝
  27. # ╔════════════════════════════════════════════════════════════════════╗
  28. # ║ Credits and Thanks:                                                ║
  29. # ║   Roninator2                                                       ║
  30. # ║   Theoallen                                                        ║
  31. # ╚════════════════════════════════════════════════════════════════════╝
  32. # ╔════════════════════════════════════════════════════════════════════╗
  33. # ║ Terms of use:                                                      ║
  34. # ║  Follow the original Authors terms of use where applicable         ║
  35. # ║    - When not made by me (Roninator2)                              ║
  36. # ║  Free for all uses in RPG Maker except nudity                      ║
  37. # ║  Anyone using this script in their project before these terms      ║
  38. # ║  were changed are allowed to use this script even if it conflicts  ║
  39. # ║  with these new terms. New terms effective 03 Apr 2024             ║
  40. # ║  No part of this code can be used with AI programs or tools        ║
  41. # ║  Credit must be given                                              ║
  42. # ╚════════════════════════════════════════════════════════════════════╝
  43.  
  44. module R2_Group_TP
  45.   BAR_WIDTH = 250
  46.   BAR_HEIGHT = 10
  47.   BAR_Y = 0
  48.   BAR_POSITION = "top"   # Position of the tp bar. Can be "top" or "bottom"
  49.   PARTY_BAR_COLORS = [4,11]
  50.   PARTY_TP_TEXT = "Party TP"
  51.   TEXT_Y = 0
  52.   SHOW_NUMBERS = true
  53.   # The following will work if preserving tp is off
  54.   RANDOM_TP_START = true
  55.   RANDOM_TP_AMOUNT = 20     # number to randomize the starting tp.
  56.   # 20 means a number between 0 and 20 for the starting tp
  57.   GUARANTEE_TP = true
  58.   GUARANTEE_TP_AMOUNT = 10  # will always start with this amount of tp + random
  59. end
  60.  
  61. #==============================================================================
  62. # ** Game Unit
  63. #------------------------------------------------------------------------------
  64. #  Adding in tp for the party
  65. #==============================================================================
  66.  
  67. class Game_Unit
  68.   def tp_rate=(value)
  69.     return tp_rate
  70.   end
  71.   def tp_rate
  72.     self.tp.to_f / max_tp
  73.   end
  74. end
  75.  
  76. #==============================================================================
  77. # ** Window Battle Status
  78. #------------------------------------------------------------------------------
  79. #  removing the tp drawn for each actor
  80. #==============================================================================
  81.  
  82. class Window_BattleStatus < Window_Selectable
  83.   def draw_gauge_area_with_tp(rect, actor)
  84.     draw_actor_hp(actor, rect.x + 0, rect.y, 72)
  85.     draw_actor_mp(actor, rect.x + 82, rect.y, 64)
  86.   end
  87. end
  88.  
  89. #==============================================================================
  90. # ** Window Group TP
  91. #------------------------------------------------------------------------------
  92. #  Draw the tp gauge for the party
  93. #==============================================================================
  94. class Window_GroupTP < Window_Base
  95.  
  96.   def initialize
  97.     super(0, 0, Graphics.width, Graphics.height)
  98.     update_location
  99.     draw_tp_bar
  100.     self.opacity = 0
  101.     self.contents_opacity = 255
  102.   end
  103.  
  104.   def bar_width
  105.     return R2_Group_TP::BAR_WIDTH
  106.   end
  107.  
  108.   def update
  109.     self.refresh
  110.   end
  111.  
  112.   def refresh
  113.     contents.clear
  114.     $game_party.tp = $game_party.battle_members[0].tp.to_i
  115.     draw_tp_bar
  116.   end
  117.  
  118.   def update_location
  119.     case R2_Group_TP::BAR_POSITION
  120.     when "top"
  121.       self.y = 0
  122.     when "bottom"
  123.       self.y = Graphics.height - 170
  124.     else
  125.       self.opacity = 0
  126.     end
  127.     self.z = 0
  128.   end
  129.  
  130.   def draw_tp_bar
  131.     draw_party_tp(Graphics.width / 2 - bar_width / 2, 0, bar_width)
  132.   end
  133.  
  134.   def draw_party_tp(x, y, width)
  135.       draw_tp_gauge(x, y, width, $game_party.tp_rate, text_color(R2_Group_TP::PARTY_BAR_COLORS[0]), text_color(R2_Group_TP::PARTY_BAR_COLORS[1]))
  136.       draw_text(x, y + R2_Group_TP::TEXT_Y, 100, contents.font.size, party_text, 2)
  137.     if R2_Group_TP::SHOW_NUMBERS
  138.       xr = x + width
  139.       draw_text(xr - 100, y + R2_Group_TP::TEXT_Y, 100, contents.font.size, $game_party.tp.to_s, 2)
  140.     end
  141.   end
  142.  
  143.   def party_text
  144.     R2_Group_TP::PARTY_TP_TEXT
  145.   end
  146.  
  147.   def draw_tp_gauge(x, y, width, rate, color1, color2)
  148.     fill_w = (width * rate).to_i
  149.     gauge_y = y + line_height - 8 + R2_Group_TP::BAR_Y
  150.     contents.fill_rect(x, gauge_y, width, R2_Group_TP::BAR_HEIGHT, gauge_back_color)
  151.     contents.gradient_fill_rect(x, gauge_y, fill_w, R2_Group_TP::BAR_HEIGHT, color1, color2)
  152.   end
  153.  
  154. end # Window_GroupTP < Window_Base
  155.  
  156. #==============================================================================
  157. # ** Scene Battle
  158. #------------------------------------------------------------------------------
  159. #  Create tp window
  160. #==============================================================================
  161. class Scene_Battle < Scene_Base
  162.  
  163.   alias r2_party_tp_start start
  164.   def start
  165.     set_initial_tp
  166.     r2_party_tp_start
  167.   end
  168.  
  169.   alias r2_party_tp_create_all_windows create_all_windows
  170.   def create_all_windows
  171.     r2_party_tp_create_all_windows
  172.     @party_tp_window = Window_GroupTP.new
  173.   end
  174.  
  175.   def set_initial_tp
  176.     if !$game_party.battle_members[0].preserve_tp?
  177.     if R2_Group_TP::RANDOM_TP_START
  178.       $game_party.battle_members[0].tp = rand(R2_Group_TP::RANDOM_TP_AMOUNT)
  179.     else
  180.       $game_party.battle_members[0].tp = 0
  181.     end
  182.     if R2_Group_TP::GUARANTEE_TP
  183.       $game_party.battle_members[0].tp += R2_Group_TP::GUARANTEE_TP_AMOUNT
  184.     end
  185.     end
  186.     $game_party.tp = $game_party.battle_members[0].tp
  187.     $game_party.tp_rate = $game_party.battle_members[0].tp_rate
  188.   end
  189.  
  190. end # Scene_Battle < Scene_Base
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement