Advertisement
roninator2

Alternate Battle Status 1

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