Advertisement
roninator2

Alternate Battle Status 1

Nov 17th, 2024 (edited)
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 36.50 KB | Source Code | 0 0
  1. # ╔═══════════════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Alternate Battle Status 1              ║  Version: 1.16     ║
  3. # ║ Author: Roninator2                            ║                    ║
  4. # ╠═══════════════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                                     ║   Date Created     ║
  6. # ║                                               ╠════════════════════╣
  7. # ║ Display Battle Status another way             ║    12 Oct 2023     ║
  8. # ╚═══════════════════════════════════════════════╩════════════════════╝
  9. # ╔════════════════════════════════════════════════════════════════════╗
  10. # ║ Requires: nil                                                      ║
  11. # ║                                                                    ║
  12. # ╚════════════════════════════════════════════════════════════════════╝
  13. # ╔════════════════════════════════════════════════════════════════════╗
  14. # ║ Brief Description:                                                 ║
  15. # ║       Provide alternate battle status view                         ║
  16. # ╚════════════════════════════════════════════════════════════════════╝
  17. # ╔════════════════════════════════════════════════════════════════════╗
  18. # ║ Instructions:                                                      ║
  19. # ║                                                                    ║
  20. # ║  Set the Icon value below for when the actor has no                ║
  21. # ║  action selected.                                                  ║
  22. # ║                                                                    ║
  23. # ║  Otherwise plug and play                                           ║
  24. # ║                                                                    ║
  25. # ║  To show the states properly you need to use a scrolling state     ║
  26. # ║  script such as Neon Black Scrolling States                        ║
  27. # ╚════════════════════════════════════════════════════════════════════╝
  28. # ╔════════════════════════════════════════════════════════════════════╗
  29. # ║ Updates:                                                           ║
  30. # ║ 1.00 - 12 Oct 2023 - Script finished                               ║
  31. # ║ 1.01 - 12 Oct 2023 - bug fix                                       ║
  32. # ║ 1.02 - 05 May 2024 - fixed Item selection                          ║
  33. # ║ 1.03 - 05 May 2024 - Updated Actor Select Window                   ║
  34. # ║ 1.04 - 08 May 2024 - Added Icon option for Gauge bars              ║
  35. # ║ 1.05 - 10 May 2024 - Changed display and added CTB support         ║
  36. # ║ 1.06 - 10 May 2024 - Changed windows display                       ║
  37. # ║ 1.07 - 12 May 2024 - Cleaned up display and added enemy HP display ║
  38. # ║ 1.08 - 12 May 2024 - Fixed stats not showing after party command   ║
  39. # ║ 1.09 - 13 May 2024 - Fixed states not showing in right position    ║
  40. # ║ 1.10 - 14 May 2024 - Redesigned for Max 4 party members in battle  ║
  41. # ║ 1.11 - 18 May 2024 - Fixed scrolling icons                         ║
  42. # ║ 1.12 - 27 May 2024 - Added scrolling icons for enemies             ║
  43. # ║ 1.13 - 28 May 2024 - Moved Actor Command Window to the Left        ║
  44. # ║ 1.14 - 17 May 2025 - Fixed enemy HP not aligning center            ║
  45. # ║ 1.15 - 17 May 2025 - Fixed Graphic glitch for scrolling icons      ║
  46. # ║ 1.16 - 18 May 2025 - Fixed Actor Status Window X position          ║
  47. # ╚════════════════════════════════════════════════════════════════════╝
  48. # ╔════════════════════════════════════════════════════════════════════╗
  49. # ║ Credits and Thanks:                                                ║
  50. # ║   Roninator2                                                       ║
  51. # ║   Yanfly                                                           ║
  52. # ╚════════════════════════════════════════════════════════════════════╝
  53. # ╔════════════════════════════════════════════════════════════════════╗
  54. # ║ Terms of use:                                                      ║
  55. # ║  Follow the original Authors terms of use where applicable         ║
  56. # ║    - When not made by me (Roninator2)                              ║
  57. # ║  Free for all uses in RPG Maker except nudity                      ║
  58. # ║  Anyone using this script in their project before these terms      ║
  59. # ║  were changed are allowed to use this script even if it conflicts  ║
  60. # ║  with these new terms. New terms effective 03 Apr 2024             ║
  61. # ║  No part of this code can be used with AI programs or tools        ║
  62. # ║  Credit must be given                                              ║
  63. # ╚════════════════════════════════════════════════════════════════════╝
  64.  
  65. module R2_ALT_BATTLE_STATUS_ONE
  66.   ACTION_ICON = 185        # Action Icons
  67.   SHOW_ACTION_ICONS = true # show action Icons
  68.   HP_ICON = 10             # HP Icon
  69.   MP_ICON = 11             # MP Icon
  70.   TP_ICON = 12             # TP Icon
  71.   SHOW_STAT_ICONS = true   # show stat Icons
  72.   SHOW_ENEMY_ICONS = true  # show icons for enemy health + health
  73.   ENEMY_COLUMNS = 1        # columns in enemy window
  74.   MAX_PARTY = 4            # max number of members in party. Must be less than 5
  75.   ICON_SCROLL_TIMER = 90   # frames to wait before next icon is shown.
  76.   BLANK_ICON = 16          # icon shown for icon placement
  77.   AP_GAUGE_WIDTH = 120     # width of AP gauge when using Circle Cross CTB
  78.   SHOW_ENEMY_STATES = true # Show enemy inflicted states and buffs
  79. end
  80.  
  81. #==============================================================================
  82. # ** BattleManager
  83. #==============================================================================
  84. module BattleManager
  85.   attr_reader :phase
  86.   #--------------------------------------------------------------------------
  87.   # * BattleManager Phase
  88.   #--------------------------------------------------------------------------
  89.   def self.phase?
  90.     return @phase
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # * Start Command Input
  94.   #--------------------------------------------------------------------------
  95.   def self.init_input
  96.     if @phase != :init
  97.       @phase = :init
  98.     end
  99.   end
  100. end
  101.  
  102. #==============================================================================
  103. # ** Game_Party
  104. #==============================================================================
  105. class Game_Party < Game_Unit
  106.   #--------------------------------------------------------------------------
  107.   # * Get Maximum Number of Battle Members
  108.   #--------------------------------------------------------------------------
  109.   def max_battle_members
  110.     return R2_ALT_BATTLE_STATUS_ONE::MAX_PARTY
  111.   end
  112. end
  113.  
  114. #==============================================================================
  115. # ** Game_Actor
  116. #==============================================================================
  117. class Game_Actor < Game_Battler
  118.   #--------------------------------------------------------------------------
  119.   # * Public Instance Variables
  120.   #--------------------------------------------------------------------------
  121.   attr_accessor :icon_scroll_index
  122.   attr_accessor :icon_scroll_timer
  123.   attr_accessor :icon_scroll_icons
  124.   #--------------------------------------------------------------------------
  125.   # * Setup
  126.   #--------------------------------------------------------------------------
  127.   alias :r2_icon_scroll_setup   :setup
  128.   def setup(actor_id)
  129.     @icon_scroll_index = 0
  130.     @icon_scroll_timer = 0
  131.     @icon_scroll_icons = []
  132.     r2_icon_scroll_setup(actor_id)
  133.   end
  134. end
  135.  
  136. #==============================================================================
  137. # ** Game_Enemy
  138. #==============================================================================
  139. class Game_Enemy < Game_Battler
  140.   #--------------------------------------------------------------------------
  141.   # * Public Instance Variables
  142.   #--------------------------------------------------------------------------
  143.   attr_accessor :icon_scroll_index
  144.   attr_accessor :icon_scroll_timer
  145.   attr_accessor :icon_scroll_icons
  146.   #--------------------------------------------------------------------------
  147.   # * Setup
  148.   #--------------------------------------------------------------------------
  149.   alias :r2_icon_scroll_initialize   :initialize
  150.   def initialize(index, enemy_id)
  151.     @icon_scroll_index = 0
  152.     @icon_scroll_timer = 0
  153.     @icon_scroll_icons = []
  154.     r2_icon_scroll_initialize(index, enemy_id)
  155.   end
  156. end
  157.  
  158. #==============================================================================
  159. # ** Window_BattleStatus
  160. #==============================================================================
  161. class Window_Base < Window
  162.   #--------------------------------------------------------------------------
  163.   # * Frame Update
  164.   #--------------------------------------------------------------------------
  165.   alias :r2_update_icon_scroll_base :update
  166.   def update
  167.     r2_update_icon_scroll_base
  168.     refresh_actor_scroll_icons
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # * refresh_actor_scroll_icons
  172.   #--------------------------------------------------------------------------
  173.   def refresh_actor_scroll_icons
  174.   end
  175. end
  176.  
  177. #==============================================================================
  178. # ** Window_BattleStatus
  179. #==============================================================================
  180. class Window_BattleStatus < Window_Selectable
  181.   attr_reader :battle_view
  182.   #--------------------------------------------------------------------------
  183.   # * Get Row Count
  184.   #--------------------------------------------------------------------------
  185.   def row_max
  186.     2
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * Get Digit Count
  190.   #--------------------------------------------------------------------------
  191.   def col_max
  192.     2
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # overwrite method: draw_item
  196.   #--------------------------------------------------------------------------
  197.   def draw_item(index)
  198.     return if index.nil?
  199.     actor = $game_party.battle_members[index]
  200.     return if actor.nil?
  201.     rect = item_rect_for_sprite(index)
  202.     contents.clear_rect(20,0,80,24)
  203.     draw_text(20, 0, 80, 24, "Party")
  204.     draw_actor_graphic(actor, rect.x, rect.y+16)
  205.     draw_actor_action(actor, rect.x+10, rect.y-16) if
  206.       R2_ALT_BATTLE_STATUS_ONE::SHOW_ACTION_ICONS == true
  207.     if BattleManager.phase? != :input
  208.       @battle_view = true
  209.       rect = item_rect_for_status(index)
  210.       draw_actor_ap(actor, rect.x+30, rect.y, R2_ALT_BATTLE_STATUS_ONE::AP_GAUGE_WIDTH) if $imported && $imported["R2_CTB_CC"] == true
  211.       draw_actor_name(actor, rect.x+10, rect.y, rect.width+20)
  212.       if R2_ALT_BATTLE_STATUS_ONE::SHOW_STAT_ICONS == true
  213.         draw_icon(R2_ALT_BATTLE_STATUS_ONE::HP_ICON, rect.x+30, rect.y+24)
  214.         draw_current_and_max_values(rect.x+8, rect.y+24, rect.width,
  215.           actor.hp, actor.mhp, hp_color(actor), normal_color)
  216.       else
  217.         draw_gauge(rect.x+30, rect.y+24, rect.width-20, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  218.         draw_current_and_max_values(rect.x+10, rect.y+24, rect.width,
  219.           actor.hp, actor.mhp, hp_color(actor), normal_color)
  220.         draw_text(rect.x+30, rect.y+24, 30, line_height, Vocab::hp_a)
  221.       end
  222.     else
  223.       return if actor != BattleManager.actor
  224.       @battle_view = false
  225.       rect = item_rect(index)
  226.       draw_actor_face(actor, rect.x, rect.y+2, actor.alive?)
  227.       draw_actor_name(actor, rect.x+100, rect.y, rect.width-8)
  228.       if R2_ALT_BATTLE_STATUS_ONE::SHOW_STAT_ICONS == true
  229.         draw_icon(R2_ALT_BATTLE_STATUS_ONE::HP_ICON, rect.x+120, line_height*1)
  230.         draw_current_and_max_values(rect.x+100, line_height*1, rect.width - rect.x - 40,
  231.           actor.hp, actor.mhp, hp_color(actor), normal_color)
  232.         draw_icon(R2_ALT_BATTLE_STATUS_ONE::MP_ICON, rect.x+120, line_height*2)
  233.         draw_current_and_max_values(rect.x+100, line_height*2, rect.width - rect.x - 40,
  234.           actor.mp.to_i, actor.mmp, mp_color(actor), normal_color)
  235.         draw_icon(R2_ALT_BATTLE_STATUS_ONE::TP_ICON, rect.x+120, line_height*3)
  236.         draw_text(rect.x+187, line_height*3, 64, line_height, actor.tp.to_i, 2)
  237.       else
  238.         draw_actor_hp(actor, rect.x+120, line_height*1, rect.width - rect.x - 30)
  239.         draw_actor_mp(actor, rect.x+120, line_height*2, rect.width - rect.x - 30)
  240.         draw_actor_tp(actor, rect.x+120, line_height*3, rect.width - rect.x - 30)
  241.       end
  242.     end
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # * Draw State and Buff/Debuff Icons
  246.   #--------------------------------------------------------------------------
  247.   def draw_actor_scroll_icons(actor)
  248.     actor.icon_scroll_icons = (actor.state_icons + actor.buff_icons)
  249.     if BattleManager.phase? != :input
  250.       # turn phase
  251.       index = 0
  252.       $game_party.battle_members.each_with_index do |mem, i|
  253.         index = i if mem.id == actor.id
  254.       end
  255.       rect = item_rect_for_status(index)
  256.       rect.x += 130
  257.     else
  258.       # party select
  259.       if BattleManager.phase? == :input && BattleManager.actor.nil?
  260.         index = 0
  261.         $game_party.battle_members.each_with_index do |mem, i|
  262.           index = i if mem.id == actor.id
  263.         end
  264.         rect = item_rect_for_status(index)
  265.         rect.x += 130
  266.       else
  267.         # actor command
  268.         return if actor != BattleManager.actor
  269.         rect = item_rect(0)
  270.         rect.x += 260
  271.       end
  272.     end
  273.     if actor.icon_scroll_timer > R2_ALT_BATTLE_STATUS_ONE::ICON_SCROLL_TIMER
  274.       actor.icon_scroll_index += 1
  275.       actor.icon_scroll_index = 0 if actor.icon_scroll_index > actor.icon_scroll_icons.size - 1
  276.       actor.icon_scroll_timer = 0
  277.     end
  278.     contents.clear_rect(rect.x-2, rect.y - 2, 28, 28)
  279.     draw_actor_state_icons(actor, rect.x, rect.y)
  280.     actor.icon_scroll_timer += 1
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   # new method: draw_actor_action
  284.   #--------------------------------------------------------------------------
  285.   def draw_actor_state_icons(actor, dx, dy)
  286.     draw_icon(state_icon(actor), dx, dy)
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # new method: action_icon
  290.   #--------------------------------------------------------------------------
  291.   def state_icon(actor)
  292.     return R2_ALT_BATTLE_STATUS_ONE::BLANK_ICON if actor.icon_scroll_icons == []
  293.     return R2_ALT_BATTLE_STATUS_ONE::BLANK_ICON if actor.icon_scroll_icons[actor.icon_scroll_index].nil?
  294.     return actor.icon_scroll_icons[0] if actor.icon_scroll_icons.size == 1
  295.     return actor.icon_scroll_icons[actor.icon_scroll_index]
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # * refresh_actor_scroll_icons
  299.   #--------------------------------------------------------------------------
  300.   def refresh_actor_scroll_icons
  301.     if BattleManager.phase? != :input && @battle_view
  302.       $game_party.battle_members.each do |mem|
  303.         draw_actor_scroll_icons(mem)
  304.       end
  305.     else
  306.       if BattleManager.phase? == :input && BattleManager.actor.nil?
  307.         $game_party.battle_members.each do |mem|
  308.           draw_actor_scroll_icons(mem)
  309.         end
  310.       else
  311.         return if BattleManager.actor.nil?
  312.         draw_actor_scroll_icons(BattleManager.actor)
  313.       end
  314.     end
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # * new method: item_rect_for_sprite
  318.   #--------------------------------------------------------------------------
  319.   def item_rect_for_sprite(index)
  320.     rect = item_rect(index)
  321.     rect.width -= 8
  322.     line = (index / 2).ceil
  323.     rect.x = index % 2 * 48 + 12
  324.     rect.y = line * 35 + 40
  325.     rect
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # * new method: item_rect_for_status
  329.   #--------------------------------------------------------------------------
  330.   def item_rect_for_status(index)
  331.     rect = item_rect(index)
  332.     rect.width = 150
  333.     line = (index / 2).ceil
  334.     rect.x = (index % 2) * 150 + 80
  335.     rect.y = line * line_height + line * 24
  336.     rect
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # overwrite method: item_rect
  340.   #--------------------------------------------------------------------------
  341.   def item_rect(index)
  342.     rect = Rect.new
  343.     rect.x = 100
  344.     rect.height = contents.height
  345.     rect.width = contents.width - rect.x
  346.     rect.y = 0
  347.     return rect
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # * Draw Item
  351.   #--------------------------------------------------------------------------
  352.   def draw_actor_data
  353.     actor = BattleManager.actor
  354.     actor.actions[0] = Game_Action.new(actor)
  355.     refresh
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # new method: draw_actor_action
  359.   #--------------------------------------------------------------------------
  360.   def draw_actor_action(actor, dx, dy)
  361.     draw_icon(action_icon(actor), dx, dy)
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # new method: action_icon
  365.   #--------------------------------------------------------------------------
  366.   def action_icon(actor)
  367.     return R2_ALT_BATTLE_STATUS_ONE::ACTION_ICON if actor.current_action.nil?
  368.     return R2_ALT_BATTLE_STATUS_ONE::ACTION_ICON if actor.current_action.item.nil?
  369.     return actor.current_action.item.icon_index
  370.   end
  371.   #--------------------------------------------------------------------------
  372.   # overwrite method: draw_face
  373.   #--------------------------------------------------------------------------
  374.   def draw_face(face_name, face_index, x, y, enabled = true)
  375.     bitmap = Cache.face(face_name)
  376.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  377.     contents.blt(x, y-2, bitmap, rect, enabled ? 255 : translucent_alpha)
  378.     bitmap.dispose
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # overwrite method: draw_actor_name
  382.   #--------------------------------------------------------------------------
  383.   def draw_actor_name(actor, dx, dy, dw = 112)
  384.     reset_font_settings
  385.     change_color(hp_color(actor))
  386.     draw_text(dx+24, dy, dw-24, line_height, actor.name)
  387.   end
  388.   #--------------------------------------------------------------------------
  389.   # overwrite method: draw_actor_hp
  390.   #--------------------------------------------------------------------------
  391.   def draw_actor_hp(actor, dx, dy, width = 124)
  392.     draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  393.     change_color(system_color)
  394.     cy = (Font.default_size - contents.font.size) / 2 + 1
  395.     draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a)
  396.     draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp,
  397.       hp_color(actor), normal_color)
  398.   end
  399.   #--------------------------------------------------------------------------
  400.   # overwrite method: draw_actor_mp
  401.   #--------------------------------------------------------------------------
  402.   def draw_actor_mp(actor, dx, dy, width = 124)
  403.     draw_gauge(dx, dy, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
  404.     change_color(system_color)
  405.     cy = (Font.default_size - contents.font.size) / 2 + 1
  406.     draw_text(dx+2, dy+cy, 30, line_height, Vocab::mp_a)
  407.     draw_current_and_max_values(dx, dy+cy, width, actor.mp.to_i, actor.mmp,
  408.       mp_color(actor), normal_color)
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # overwrite method: draw_actor_tp
  412.   #--------------------------------------------------------------------------
  413.   def draw_actor_tp(actor, dx, dy, width = 124)
  414.     draw_gauge(dx, dy, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
  415.     change_color(system_color)
  416.     cy = (Font.default_size - contents.font.size) / 2 + 1
  417.     draw_text(dx+2, dy+cy, 30, line_height, Vocab::tp_a)
  418.     change_color(tp_color(actor))
  419.     draw_text(dx + width - 42, dy+cy, 42, line_height, actor.tp.to_i, 2)
  420.   end
  421. end
  422.  
  423. #==============================================================================
  424. # ** Window_BattleActor
  425. #==============================================================================
  426. class Window_BattleActor < Window_BattleStatus
  427.   #--------------------------------------------------------------------------
  428.   # * Object Initialization
  429.   #     info_viewport : Viewport for displaying information
  430.   #--------------------------------------------------------------------------
  431.   def initialize(info_viewport)
  432.     super()
  433.     self.y = info_viewport.rect.y
  434.     self.visible = false
  435.     self.openness = 255
  436.     self.opacity = 255
  437.   end
  438.   #--------------------------------------------------------------------------
  439.   # overwrite method: item_rect
  440.   #--------------------------------------------------------------------------
  441.   def item_rect(index)
  442.     rect = Rect.new
  443.     rect.x = 0
  444.     rect.height = 32
  445.     rect.width = 48
  446.     rect.y = 0
  447.     line = (index / 2).ceil
  448.     rect.x = index % 2 * 48
  449.     rect.y = line * 35 + 24
  450.     rect
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # * new method: item_rect_for_sprite
  454.   #--------------------------------------------------------------------------
  455.   def item_rect_for_sprite(index)
  456.     rect = item_rect(index)
  457.     rect.width -= 8
  458.     line = (index / 2).ceil
  459.     rect.x = index % 2 * 48 + 12
  460.     rect.y = line * 35 + 40
  461.     rect
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # overwrite method: item_rect
  465.   #--------------------------------------------------------------------------
  466.   def item_face_rect(index)
  467.     rect = Rect.new
  468.     rect.x = 80
  469.     rect.height = contents.height
  470.     rect.width = contents.width - rect.x
  471.     rect.y = 0
  472.     return rect
  473.   end
  474.   #--------------------------------------------------------------------------
  475.   # overwrite method: draw_item
  476.   #--------------------------------------------------------------------------
  477.   def draw_item(index)
  478.     return if index.nil?
  479.     actor = $game_party.battle_members[index]
  480.     return if actor.nil?
  481.     rect = item_rect_for_sprite(index)
  482.     contents.clear_rect(20, 0, 80, 24)
  483.     draw_text(20, 0, 80, 24, "Party")
  484.     draw_actor_graphic(actor, rect.x, rect.y+16)
  485.     draw_actor_action(actor, rect.x+10, rect.y-16)
  486.   end
  487.   #--------------------------------------------------------------------------
  488.   # * Cursor Movement Processing
  489.   #--------------------------------------------------------------------------
  490.   alias :r2_cursor_move   :process_cursor_move
  491.   def process_cursor_move
  492.     last_index = @index
  493.     r2_cursor_move
  494.     refresh if @index != last_index
  495.   end
  496.   #--------------------------------------------------------------------------
  497.   # * Refresh
  498.   #--------------------------------------------------------------------------
  499.   alias :r2_actor_refresh :refresh
  500.   def refresh
  501.     r2_actor_refresh
  502.     draw_selection
  503.   end
  504.   #--------------------------------------------------------------------------
  505.   # * Draw Current Selection for Actor
  506.   #--------------------------------------------------------------------------
  507.   def draw_selection
  508.     @index = 0 if @index == -1
  509.     actor = $game_party.battle_members[@index]
  510.     rect = item_face_rect(index)
  511.     draw_actor_face(actor, rect.x+20, rect.y+2, actor.alive?)
  512.     draw_actor_name(actor, rect.x+120, rect.y, rect.width-8)
  513.     if R2_ALT_BATTLE_STATUS_ONE::SHOW_STAT_ICONS == true
  514.       draw_icon(R2_ALT_BATTLE_STATUS_ONE::HP_ICON, rect.x+140, line_height*1)
  515.       draw_current_and_max_values(rect.x+80, line_height*1, rect.width - rect.x - 40,
  516.         actor.hp, actor.mhp, hp_color(actor), normal_color)
  517.       draw_icon(R2_ALT_BATTLE_STATUS_ONE::MP_ICON, rect.x+140, line_height*2)
  518.       draw_current_and_max_values(rect.x+80, line_height*2, rect.width - rect.x - 40,
  519.         actor.mp.to_i, actor.mmp, mp_color(actor), normal_color)
  520.       draw_icon(R2_ALT_BATTLE_STATUS_ONE::TP_ICON, rect.x+140, line_height*3)
  521.       draw_text(rect.x+207, line_height*3, 64, line_height, actor.tp.to_i, 2)
  522.     else
  523.       draw_actor_hp(actor, rect.x+140, line_height*1, rect.width - rect.x - 70)
  524.       draw_actor_mp(actor, rect.x+140, line_height*2, rect.width - rect.x - 70)
  525.       draw_actor_tp(actor, rect.x+140, line_height*3, rect.width - rect.x - 70)
  526.     end
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # * Draw Face Graphic
  530.   #     enabled : Enabled flag. When false, draw semi-transparently.
  531.   #--------------------------------------------------------------------------
  532.   def draw_face(face_name, face_index, x, y, enabled = true)
  533.     bitmap = Cache.face(face_name)
  534.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  535.     contents.blt(x, y-2, bitmap, rect, enabled ? 255 : translucent_alpha)
  536.     bitmap.dispose
  537.   end
  538.   #--------------------------------------------------------------------------
  539.   # * Draw State and Buff/Debuff Icons
  540.   #--------------------------------------------------------------------------
  541.   def draw_actor_scroll_icons(actor)
  542.     actor.icon_scroll_icons = (actor.state_icons + actor.buff_icons)
  543.     rect = item_face_rect(0)
  544.     rect.x += 280
  545.     if actor.icon_scroll_timer > R2_ALT_BATTLE_STATUS_ONE::ICON_SCROLL_TIMER
  546.       actor.icon_scroll_index += 1
  547.       actor.icon_scroll_index = 0 if actor.icon_scroll_index > actor.icon_scroll_icons.size - 1
  548.       actor.icon_scroll_timer = 0
  549.     end
  550.     contents.clear_rect(rect.x-2, rect.y - 2, 28, 28)
  551.     draw_actor_state_icons(actor, rect.x, rect.y)
  552.     actor.icon_scroll_timer += 1
  553.   end
  554.   #--------------------------------------------------------------------------
  555.   # new method: draw_actor_action
  556.   #--------------------------------------------------------------------------
  557.   def draw_actor_state_icons(actor, dx, dy)
  558.     draw_icon(state_icon(actor), dx, dy)
  559.   end
  560.   #--------------------------------------------------------------------------
  561.   # new method: action_icon
  562.   #--------------------------------------------------------------------------
  563.   def state_icon(actor)
  564.     return R2_ALT_BATTLE_STATUS_ONE::BLANK_ICON if actor.icon_scroll_icons == []
  565.     return R2_ALT_BATTLE_STATUS_ONE::BLANK_ICON if actor.icon_scroll_icons[actor.icon_scroll_index].nil?
  566.     return actor.icon_scroll_icons[0] if actor.icon_scroll_icons.size == 1
  567.     return actor.icon_scroll_icons[actor.icon_scroll_index]
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # * refresh_actor_scroll_icons
  571.   #--------------------------------------------------------------------------
  572.   def refresh_actor_scroll_icons
  573.     return if BattleManager.actor.nil?
  574.     actor = $game_party.battle_members[@index]
  575.     draw_actor_scroll_icons(actor)
  576.   end
  577. end
  578.  
  579. #==============================================================================
  580. # ** Window_BattleEnemy
  581. #==============================================================================
  582. class Window_BattleEnemy < Window_Selectable
  583.   #--------------------------------------------------------------------------
  584.   # * Object Initialization
  585.   #     info_viewport : Viewport for displaying information
  586.   #--------------------------------------------------------------------------
  587.   def initialize(info_viewport)
  588.     super(0, info_viewport.rect.y, window_width, 120)
  589.     refresh
  590.     self.visible = false
  591.     @info_viewport = info_viewport
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # * Draw Item
  595.   #--------------------------------------------------------------------------
  596.   def draw_item(index)
  597.     change_color(normal_color)
  598.     rect = item_rect_for_text(index)
  599.     enmy = $game_troop.alive_members[index]
  600.     name = enmy.name
  601.     draw_text(rect, name)
  602.     if R2_ALT_BATTLE_STATUS_ONE::SHOW_ENEMY_ICONS
  603.       if col_max == 1
  604.         draw_icon(R2_ALT_BATTLE_STATUS_ONE::HP_ICON, rect.x+200, rect.y)
  605.         draw_current_and_max_values(rect.x, rect.y, rect.width - rect.x - 40,
  606.         enmy.hp.to_i, enmy.mhp, hp_color(enmy), normal_color)
  607.       else
  608.         draw_icon(R2_ALT_BATTLE_STATUS_ONE::HP_ICON, rect.x+100, rect.y)
  609.         rect.x += 140
  610.         draw_text(rect, enmy.hp)
  611.       end
  612.       draw_enemy_scroll_icons(index, enmy)
  613.     end
  614.   end
  615.   #--------------------------------------------------------------------------
  616.   # * Get Digit Count
  617.   #--------------------------------------------------------------------------
  618.   def col_max
  619.     R2_ALT_BATTLE_STATUS_ONE::ENEMY_COLUMNS
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   # * Get Line Height
  623.   #--------------------------------------------------------------------------
  624.   def line_height
  625.     return 26
  626.   end
  627.   #--------------------------------------------------------------------------
  628.   # * Get Standard Padding Size
  629.   #--------------------------------------------------------------------------
  630.   def standard_padding
  631.     return 8
  632.   end
  633.   #--------------------------------------------------------------------------
  634.   # * Draw State and Buff/Debuff Icons
  635.   #--------------------------------------------------------------------------
  636.   def draw_enemy_scroll_icons(index, enmy)
  637.     return unless R2_ALT_BATTLE_STATUS_ONE::SHOW_ENEMY_STATES
  638.     rect = item_rect_for_text(index)
  639.     rect.x += 360
  640.     enmy.icon_scroll_icons = (enmy.state_icons + enmy.buff_icons)
  641.     if enmy.icon_scroll_timer > R2_ALT_BATTLE_STATUS_ONE::ICON_SCROLL_TIMER
  642.       enmy.icon_scroll_index += 1
  643.       enmy.icon_scroll_index = 0 if enmy.icon_scroll_index > enmy.icon_scroll_icons.size - 1
  644.       enmy.icon_scroll_timer = 0
  645.     end
  646.     contents.clear_rect(rect.x-2, rect.y - 2, 28, 28)
  647.     draw_enemy_state_icons(enmy, rect.x, rect.y)
  648.     enmy.icon_scroll_timer += 2
  649.   end
  650.   #--------------------------------------------------------------------------
  651.   # new method: draw_actor_action
  652.   #--------------------------------------------------------------------------
  653.   def draw_enemy_state_icons(enmy, dx, dy)
  654.     draw_icon(state_icon(enmy), dx, dy)
  655.   end
  656.   #--------------------------------------------------------------------------
  657.   # new method: action_icon
  658.   #--------------------------------------------------------------------------
  659.   def state_icon(enmy)
  660.     return R2_ALT_BATTLE_STATUS_ONE::BLANK_ICON if enmy.icon_scroll_icons == []
  661.     return R2_ALT_BATTLE_STATUS_ONE::BLANK_ICON if enmy.icon_scroll_icons[enmy.icon_scroll_index].nil?
  662.     return enmy.icon_scroll_icons[0] if enmy.icon_scroll_icons.size == 1
  663.     return enmy.icon_scroll_icons[enmy.icon_scroll_index]
  664.   end
  665.   #--------------------------------------------------------------------------
  666.   # * refresh_enemy_scroll_icons
  667.   #--------------------------------------------------------------------------
  668.   def refresh_enemy_scroll_icons
  669.     return unless active
  670.     $game_troop.alive_members.each_with_index do |mem, i|
  671.       draw_enemy_scroll_icons(i, mem)
  672.     end
  673.   end
  674. end
  675.  
  676. #==============================================================================
  677. # ** Scene_Battle
  678. #==============================================================================
  679. class Scene_Battle < Scene_Base
  680.   #--------------------------------------------------------------------------
  681.   # * Start Actor Command Selection
  682.   #--------------------------------------------------------------------------
  683.   alias :r2_actor_command_icon_scroll :start_actor_command_selection
  684.   def start_actor_command_selection
  685.     @status_window.draw_actor_data
  686.     r2_actor_command_icon_scroll
  687.   end
  688.   #--------------------------------------------------------------------------
  689.   # * To Previous Command Input
  690.   #--------------------------------------------------------------------------
  691.   def prior_command
  692.     if BattleManager.prior_command
  693.       start_actor_command_selection
  694.     else
  695.       BattleManager.init_input
  696.       @status_window.refresh
  697.       start_party_command_selection
  698.     end
  699.   end
  700.   #--------------------------------------------------------------------------
  701.   # * Start Actor Selection
  702.   #--------------------------------------------------------------------------
  703.   alias :r2_select_actor_status_window    :select_actor_selection
  704.   def select_actor_selection
  705.     r2_select_actor_status_window
  706.     @actor_window.x = @actor_command_window.width
  707.     @status_window.hide
  708.   end
  709.   #--------------------------------------------------------------------------
  710.   # * Actor [OK]
  711.   #--------------------------------------------------------------------------
  712.   alias :r2_actor_ok_status_window    :on_actor_ok
  713.   def on_actor_ok
  714.     @status_window.show
  715.     r2_actor_ok_status_window
  716.   end
  717.   #--------------------------------------------------------------------------
  718.   # * Actor [Cancel]
  719.   #--------------------------------------------------------------------------
  720.   alias :r2_actor_cancel_status_window    :on_actor_cancel
  721.   def on_actor_cancel
  722.     @status_window.show
  723.     r2_actor_cancel_status_window
  724.   end
  725.   #--------------------------------------------------------------------------
  726.   # * Frame Update
  727.   #--------------------------------------------------------------------------
  728.   alias :r2_update_icon_scroll  :update
  729.   def update
  730.     r2_update_icon_scroll
  731.     @status_window.refresh_actor_scroll_icons
  732.     @enemy_window.refresh_enemy_scroll_icons
  733.   end
  734.   #--------------------------------------------------------------------------
  735.   # * Update Information Display Viewport
  736.   #--------------------------------------------------------------------------
  737.   def update_info_viewport
  738.     move_info_viewport(0)   if @party_command_window.active
  739.     move_info_viewport(0)   if @actor_command_window.active
  740.     move_info_viewport(64)  if BattleManager.in_turn?
  741.   end
  742.   #--------------------------------------------------------------------------
  743.   # * Create Actor Commands Window
  744.   #--------------------------------------------------------------------------
  745.   def create_actor_command_window
  746.     @actor_command_window = Window_ActorCommand.new
  747.     @actor_command_window.viewport = @info_viewport
  748.     @actor_command_window.set_handler(:attack, method(:command_attack))
  749.     @actor_command_window.set_handler(:skill,  method(:command_skill))
  750.     @actor_command_window.set_handler(:guard,  method(:command_guard))
  751.     @actor_command_window.set_handler(:item,   method(:command_item))
  752.     @actor_command_window.set_handler(:cancel, method(:prior_command))
  753.   end
  754. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement