Advertisement
roninator2

CTB System - Circle Cross - Show ATB for Enemies

Dec 17th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.96 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Show ATB Bar for Enemies     ║  Version: 1.02     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║   Show Enemy ATB Bar                ║    06 Jun 2023     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Instructions:                                            ║
  11. # ║   Adjust the settings below                              ║
  12. # ║                                                          ║
  13. # ║   Due to the positioning of the enemy,                   ║
  14. # ║   you will likely need to adjust the bar position        ║
  15. # ║   so that the adjustment numbers are negative.           ║
  16. # ║   This is because I used the enemies screen position     ║
  17. # ║   which causes the bar to be at the bottom of the        ║
  18. # ║   enemy position. The window is also set to not          ║
  19. # ║   overlap the status window.                             ║
  20. # ║                                                          ║
  21. # ║   Requires Circle Cross AP script                        ║
  22. # ╚══════════════════════════════════════════════════════════╝
  23. # ╔══════════════════════════════════════════════════════════╗
  24. # ║ Terms of use:                                            ║
  25. # ║ Free for all uses in RPG Maker - Except Nudity           ║
  26. # ╚══════════════════════════════════════════════════════════╝
  27.  
  28. # ╔══════════════════════════════════════════════════════════╗
  29. # ║ Customize below:                                         ║
  30. # ╚══════════════════════════════════════════════════════════╝
  31. module R2_AP_Gauge_Pos
  32.   X_Adjust  = -70         # x position of the bar from the enemy position
  33.   Y_Adjust  = -20         # y position of the bar from the enemy position
  34.   EAP_Width  = 100        # Enemy Bar width
  35.   EAP_Height = 12         # Enemy Bar height
  36.   Enemy_Colour_1 = 17     # Starting colour of bar
  37.   Enemy_Colour_2 = 29     # Ending colour of bar
  38.   Draw_Enemy_Name = false # Draw enemy name
  39.   EAP_Name_Below = true   # Draw Enemy Name below gauge
  40.   AAP_Width  = 100        # Actor Bar width
  41.   AAP_Height = 10         # Actor Bar height
  42.   Actor_Colour_1 = 30     # Starting colour of bar
  43.   Actor_Colour_2 = 31     # Ending colour of bar
  44. end
  45. # ╔══════════════════════════════════════════════════════════╗
  46. # ║ End of Customization                                     ║
  47. # ╚══════════════════════════════════════════════════════════╝
  48.  
  49. #==============================================================================
  50. # Enemy AP
  51. #==============================================================================
  52. class Window_Enemy_AP < Window_Base
  53.   #--------------------------------------------------------------------------
  54.   # * Object Initialization
  55.   #     info_viewport : Viewport for displaying information
  56.   #--------------------------------------------------------------------------
  57.   def initialize(status)
  58.     super(0, 0, Graphics.width, Graphics.height - status)
  59.     self.opacity = 0
  60.     self.contents_opacity = 255
  61.     self.back_opacity = 0
  62.     self.z = 1
  63.     refresh
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # * Refresh
  67.   #--------------------------------------------------------------------------
  68.   def refresh
  69.     contents.clear
  70.     draw_all_items
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # * Draw All Items
  74.   #--------------------------------------------------------------------------
  75.   def draw_all_items
  76.     item_max.times {|i| draw_item(i) }
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # * Get Number of Items
  80.   #--------------------------------------------------------------------------
  81.   def item_max
  82.     $game_troop.alive_members.size
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # * Get Spacing for Items Arranged Side by Side
  86.   #--------------------------------------------------------------------------
  87.   def spacing
  88.     return 32
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ○ Assigning gauge colors
  92.   #--------------------------------------------------------------------------
  93.   def eap_gauge_color1;   text_color(R2_AP_Gauge_Pos::Enemy_Colour_1);  end
  94.   def eap_gauge_color2;   text_color(R2_AP_Gauge_Pos::Enemy_Colour_2);  end
  95.   #--------------------------------------------------------------------------
  96.   # ○ AP Drawing
  97.   #--------------------------------------------------------------------------
  98.   def draw_enemy_ap(enemy, x, y, width = 124)
  99.     draw_e_gauge(x, y, width, enemy.ap_rate, eap_gauge_color1, eap_gauge_color2)
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # * Get Rectangle for Drawing Items
  103.   #--------------------------------------------------------------------------
  104.   def item_rect(index)
  105.     enmy = $game_troop.alive_members[index]
  106.     rect = Rect.new
  107.     rect.width = R2_AP_Gauge_Pos::EAP_Width
  108.     rect.height = R2_AP_Gauge_Pos::EAP_Height
  109.     rect.height += 30 if R2_AP_Gauge_Pos::EAP_Name_Below
  110.     rect.x = enmy.screen_x + R2_AP_Gauge_Pos::X_Adjust
  111.     rect.y = enmy.screen_y + R2_AP_Gauge_Pos::Y_Adjust
  112.     rect
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # * Get Rectangle for Drawing Items (for Text)
  116.   #--------------------------------------------------------------------------
  117.   def item_rect_for_text(index)
  118.     rect = item_rect(index)
  119.     rect.x += 4
  120.     rect.y -= 8
  121.     rect.width -= 8
  122.     rect.height += 8
  123.     rect
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ○ Draw a basic area
  127.   #--------------------------------------------------------------------------
  128.   def draw_basic_area(rect, enemy)
  129.     width = R2_AP_Gauge_Pos::EAP_Width
  130.     draw_enemy_ap(enemy, rect.x + 0, rect.y, width)
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # * Draw Item
  134.   #--------------------------------------------------------------------------
  135.   def draw_item(index)
  136.     change_color(normal_color)
  137.     enemy = $game_troop.alive_members[index]
  138.     draw_basic_area(basic_area_rect(index), enemy)
  139.     name = $game_troop.alive_members[index].name
  140.     draw_text(item_rect_for_text(index), name) if R2_AP_Gauge_Pos::Draw_Enemy_Name
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # * Get Basic Area Retangle
  144.   #--------------------------------------------------------------------------
  145.   def basic_area_rect(index)
  146.     rect = item_rect_for_text(index)
  147.     rect.width -= 210
  148.     rect
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # * Draw Gauge
  152.   #     rate   : Rate (full at 1.0)
  153.   #     color1 : Left side gradation
  154.   #     color2 : Right side gradation
  155.   #--------------------------------------------------------------------------
  156.   def draw_e_gauge(x, y, width, rate, color1, color2)
  157.     fill_w = (width * rate).to_i
  158.     gauge_y = y + line_height - 8 - R2_AP_Gauge_Pos::EAP_Height
  159.     gauge_h = R2_AP_Gauge_Pos::EAP_Height
  160.     contents.fill_rect(x, gauge_y, width, gauge_h, gauge_back_color)
  161.     contents.gradient_fill_rect(x, gauge_y, fill_w, gauge_h, color1, color2)
  162.   end
  163. end
  164.  
  165. #==============================================================================
  166. # ** Window_BattleStatus
  167. #==============================================================================
  168.  
  169. class Window_BattleStatus < Window_Selectable
  170.   #--------------------------------------------------------------------------
  171.   # * Draw Basic Area
  172.   #--------------------------------------------------------------------------
  173.   alias r2_atb_draw_basic_area draw_basic_area
  174.   def draw_basic_area(rect, actor)
  175.     width = R2_AP_Gauge_Pos::AAP_Width
  176.     draw_actor_ap(actor, rect.x + 0, rect.y, width)
  177.     r2_atb_draw_basic_area(rect, actor)
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ○ Assigning gauge colors
  181.   #--------------------------------------------------------------------------
  182.   def ap_gauge_color1;   text_color(R2_AP_Gauge_Pos::Actor_Colour_1);  end
  183.   def ap_gauge_color2;   text_color(R2_AP_Gauge_Pos::Actor_Colour_2);  end
  184.   #--------------------------------------------------------------------------
  185.   # ○ AP Gauge
  186.   #--------------------------------------------------------------------------
  187.   def draw_actor_ap(actor, x, y, width = 124)
  188.     draw_ap_gauge(x, y, width, actor.ap_rate, ap_gauge_color1, ap_gauge_color2)
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # * Draw Gauge
  192.   #     rate   : Rate (full at 1.0)
  193.   #     color1 : Left side gradation
  194.   #     color2 : Right side gradation
  195.   #--------------------------------------------------------------------------
  196.   def draw_ap_gauge(x, y, width, rate, color1, color2)
  197.     fill_w = (width * rate).to_i
  198.     gauge_y = y + line_height - 4 - R2_AP_Gauge_Pos::AAP_Height
  199.     gauge_h = R2_AP_Gauge_Pos::AAP_Height
  200.     contents.fill_rect(x, gauge_y, width, gauge_h, gauge_back_color)
  201.     contents.gradient_fill_rect(x, gauge_y, fill_w, gauge_h, color1, color2)
  202.   end
  203. end
  204.  
  205. #==============================================================================
  206. # Scene_Battle
  207. #==============================================================================
  208.  
  209. class Scene_Battle < Scene_Base
  210.   #--------------------------------------------------------------------------
  211.   # * Create Enemy Window
  212.   #--------------------------------------------------------------------------
  213.   alias r2_enemy_ap_window_create create_enemy_window
  214.   def create_enemy_window
  215.     r2_enemy_ap_window_create
  216.     @enemy_ap = Window_Enemy_AP.new(@status_window.height)
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ○ Redraw the information in the status window
  220.   #--------------------------------------------------------------------------
  221.   alias r2_redraw_ap_status redraw_status
  222.   def redraw_status
  223.     r2_redraw_ap_status
  224.     @enemy_ap.refresh
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # * Processing at End of Action
  228.   #--------------------------------------------------------------------------
  229.   alias r2_action_end_refresh_ap_gauge  process_action_end
  230.   def process_action_end
  231.     @enemy_ap.refresh
  232.     r2_action_end_refresh_ap_gauge
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # * [Skill] Command
  236.   #--------------------------------------------------------------------------
  237.   alias r2_show_ap_enemy_skill_command  command_skill
  238.   def command_skill
  239.     r2_show_ap_enemy_skill_command
  240.     @enemy_ap.hide
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # * Skill [OK]
  244.   #--------------------------------------------------------------------------
  245.   alias r2_skill_ok_ap_hide   on_skill_ok
  246.   def on_skill_ok
  247.     @enemy_ap.show
  248.     r2_skill_ok_ap_hide
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # * Skill [Cancel]
  252.   #--------------------------------------------------------------------------
  253.   alias r2_on_skill_ap_cancel_window   on_skill_cancel
  254.   def on_skill_cancel
  255.     @enemy_ap.show
  256.     r2_on_skill_ap_cancel_window
  257.   end
  258. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement