Advertisement
roninator2

Kid Friendly Basic Quest - Battle Status

Dec 14th, 2024
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.16 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: KFBQ Battle Status Override  ║  Version: 1.01     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║   FFMQ Style Battle Status Window   ║    12 Mar 2023     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Instructions:                                            ║
  11. # ║                                                          ║
  12. # ║  none                                                    ║
  13. # ╚══════════════════════════════════════════════════════════╝
  14. # ╔══════════════════════════════════════════════════════════╗
  15. # ║ Terms of use:                                            ║
  16. # ║ Free for all uses in RPG Maker - Except nudity           ║
  17. # ╚══════════════════════════════════════════════════════════╝
  18.  
  19. #==============================================================================
  20. # ** Window_BattleStatus
  21. #==============================================================================
  22.  
  23. class Window_BattleStatus < Window_Selectable
  24.   #--------------------------------------------------------------------------
  25.   # * Public Instance Variables
  26.   #--------------------------------------------------------------------------
  27.   attr_reader   :pending_index            # Pending position (for formation)
  28.   #--------------------------------------------------------------------------
  29.   # * Object Initialization
  30.   #--------------------------------------------------------------------------
  31.   def initialize
  32.     super(0, 0, window_width, window_height)
  33.     @pending_index = -1
  34.     self.z = 3150
  35.     self.back_opacity = 0
  36.     self.openness = 0
  37.     self.contents_opacity = 255
  38.     refresh
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # * Get Window Width
  42.   #--------------------------------------------------------------------------
  43.   def window_width
  44.     Graphics.width
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # * Get Window Height
  48.   #--------------------------------------------------------------------------
  49.   def window_height
  50.     100
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Column Maximum
  54.   #--------------------------------------------------------------------------
  55.   def col_max
  56.     2
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # * Get Number of Items
  60.   #--------------------------------------------------------------------------
  61.   def item_max
  62.     $game_party.members.size
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # * Get Item Height
  66.   #--------------------------------------------------------------------------
  67.   def item_height
  68.     (height - standard_padding * 2)
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # * Get Item Width
  72.   #--------------------------------------------------------------------------
  73.   def item_width
  74.     window_width / col_max - spacing
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # * Item Rect
  78.   #--------------------------------------------------------------------------
  79.   def item_rect(index)
  80.     rect = Rect.new
  81.     rect.width = item_width
  82.     rect.height = item_height
  83.     rect.x = index % col_max * (item_width + spacing)
  84.     rect.y = index / col_max * item_height
  85.     rect
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # * Update Cursor
  89.   #--------------------------------------------------------------------------
  90.   def update_cursor
  91.     cursor_rect.empty
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Draw Item
  95.   #--------------------------------------------------------------------------
  96.   def draw_item(index)
  97.     actor = $game_party.members[index]
  98.     enabled = $game_party.battle_members.include?(actor)
  99.     rect = item_rect(index)
  100.     draw_item_background(index)
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # * Refresh
  104.   #--------------------------------------------------------------------------
  105.   def refresh
  106.     contents.clear
  107.     draw_all_items
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # * Draw Background for Item
  111.   #--------------------------------------------------------------------------
  112.   def draw_item_background(index)
  113.     if index == @pending_index
  114.       contents.fill_rect(item_rect(index), pending_color)
  115.     end
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # * Processing When OK Button Is Pressed
  119.   #--------------------------------------------------------------------------
  120.   def process_ok
  121.     super
  122.     $game_party.menu_actor = $game_party.members[index]
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # * Restore Previous Selection Position
  126.   #--------------------------------------------------------------------------
  127.   def select_last
  128.     select($game_party.menu_actor.index || 0)
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # * Pending Colour
  132.   #--------------------------------------------------------------------------
  133.   def pending_color
  134.     windowskin.get_pixel(116, 100)
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # * Set Pending Position (for Formation)
  138.   #--------------------------------------------------------------------------
  139.   def pending_index=(index)
  140.     last_pending_index = @pending_index
  141.     @pending_index = index
  142.     redraw_item(@pending_index)
  143.     redraw_item(last_pending_index)
  144.   end
  145. end
  146.  
  147. #==============================================================================
  148. # ** Window_MenuActor
  149. #==============================================================================
  150. class Window_BattleActor < Window_BattleStatus
  151.   #--------------------------------------------------------------------------
  152.   # * Object Initialization
  153.   #--------------------------------------------------------------------------
  154.   def initialize(info_viewport)
  155.     super()
  156.     self.y = Graphics.height - 100#info_viewport.rect.y
  157.     self.visible = false
  158.     self.openness = 255
  159.     @info_viewport = info_viewport
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # * Processing When OK Button Is Pressed
  163.   #--------------------------------------------------------------------------
  164.   def process_ok
  165.     $game_party.target_actor = $game_party.members[index] unless @cursor_all
  166.     call_ok_handler
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # * Restore Previous Selection Position
  170.   #--------------------------------------------------------------------------
  171.   def select_last
  172.     select($game_party.target_actor.index || 0)
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # * Set Position of Cursor for Item
  176.   #--------------------------------------------------------------------------
  177.   def select_for_item(item)
  178.     @cursor_fix = item.for_user?
  179.     @cursor_all = item.for_all?
  180.     if @cursor_fix
  181.       select($game_party.menu_actor.index)
  182.     elsif @cursor_all
  183.       select(0)
  184.     else
  185.       select_last
  186.     end
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * Show Window
  190.   #--------------------------------------------------------------------------
  191.   def show
  192.     if @info_viewport
  193.       width_remain = Graphics.width - width
  194.       self.x = width_remain
  195.       @info_viewport.rect.width = width_remain
  196.       select(0)
  197.     end
  198.     super
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # * Hide Window
  202.   #--------------------------------------------------------------------------
  203.   def hide
  204.     @info_viewport.rect.width = Graphics.width if @info_viewport
  205.     super
  206.   end
  207. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement