Advertisement
roninator2

Kid Friendly Basic Quest - Battle Log

Dec 13th, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.31 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: KFBQ Battle Log Override     ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║   FFMQ Style Battle Log             ║    13 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_BattleLog
  21. #==============================================================================
  22. class Window_BattleLog < Window_Selectable
  23.   #--------------------------------------------------------------------------
  24.   # * Object Initialization
  25.   #--------------------------------------------------------------------------
  26.   def initialize
  27.     super(0, 0, window_width, window_height)
  28.     self.z = -1 # <- added to hide window
  29.     self.opacity = 0
  30.     @lines = []
  31.     @num_wait = 0
  32.     create_back_bitmap
  33.     create_back_sprite
  34.     refresh
  35.   end
  36.   def max_line_number
  37.     return 1
  38.   end
  39. end
  40.  
  41. #==============================================================================
  42. # ** KFBQ_BattleLog
  43. #==============================================================================
  44. class KFBQ_BattleLog < Window_Selectable
  45.   #--------------------------------------------------------------------------
  46.   # * Object Initialization
  47.   #--------------------------------------------------------------------------
  48.   def initialize
  49.     super(20, Graphics.height - 148, window_width, window_height)
  50.     self.z = 200
  51.     self.opacity = 0
  52.     self.back_opacity = 255
  53.     @lines = []
  54.     @num_wait = 0
  55.     refresh
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # * Get Window Width
  59.   #--------------------------------------------------------------------------
  60.   def window_width
  61.     Graphics.width - 40
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # * Get Window Height
  65.   #--------------------------------------------------------------------------
  66.   def window_height
  67.     fitting_height(max_line_number)
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # * Get Maximum Number of Lines
  71.   #--------------------------------------------------------------------------
  72.   def max_line_number
  73.     return 1
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # * Clear
  77.   #--------------------------------------------------------------------------
  78.   def clear
  79.     @num_wait = 0
  80.     @lines.clear
  81.     self.opacity = 0
  82.     refresh
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # * Open Log Window
  86.   #--------------------------------------------------------------------------
  87.   def show_message
  88.     self.opacity = 255
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # * Get Number of Data Lines
  92.   #--------------------------------------------------------------------------
  93.   def line_number
  94.     @lines.size
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # * Go Back One Line
  98.   #--------------------------------------------------------------------------
  99.   def back_one
  100.     @lines.pop
  101.     refresh
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # * Return to Designated Line
  105.   #--------------------------------------------------------------------------
  106.   def back_to(line_number)
  107.     @lines.pop while @lines.size > line_number
  108.     refresh
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # * Add Text
  112.   #--------------------------------------------------------------------------
  113.   def add_text(text)
  114.     @lines.push(text)
  115.     show_message
  116.     refresh
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # * Replace Text
  120.   #    Replaces the last line with different text.
  121.   #--------------------------------------------------------------------------
  122.   def replace_text(text)
  123.     @lines.pop
  124.     @lines.push(text)
  125.     refresh
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # * Get Text From Last Line
  129.   #--------------------------------------------------------------------------
  130.   def last_text
  131.     @lines[-1]
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # * Refresh
  135.   #--------------------------------------------------------------------------
  136.   def refresh
  137.     contents.clear
  138.     @lines.size.times {|i| draw_line(i) }
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # * Draw Line
  142.   #--------------------------------------------------------------------------
  143.   def draw_line(line_number)
  144.     rect = item_rect_for_text(line_number)
  145.     contents.clear_rect(rect)
  146.     draw_text_ex(rect.x, rect.y, @lines[line_number])
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # * Set Wait Method
  150.   #--------------------------------------------------------------------------
  151.   def method_wait=(method)
  152.     @method_wait = method
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # * Set Wait Method for Effect Execution
  156.   #--------------------------------------------------------------------------
  157.   def method_wait_for_effect=(method)
  158.     @method_wait_for_effect = method
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # * Wait
  162.   #--------------------------------------------------------------------------
  163.   def wait
  164.     @num_wait += 1
  165.     if Input.press?(:A) || Input.press?(:B) || Input.press?(:C)
  166.       @num_wait = message_speed
  167.     end
  168.     @method_wait.call(message_speed) if @method_wait
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # * Wait Until Effect Execution Ends
  172.   #--------------------------------------------------------------------------
  173.   def wait_for_effect
  174.     @method_wait_for_effect.call if @method_wait_for_effect
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # * Get Message Speed
  178.   #--------------------------------------------------------------------------
  179.   def message_speed
  180.     return 30
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * Wait and Clear
  184.   #    Clear after inputing minimum necessary wait for the message to be read.
  185.   #--------------------------------------------------------------------------
  186.   def wait_and_clear
  187.     wait while @num_wait < 2 if line_number > 0
  188.     clear
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # * Display Skill/Item Use
  192.   #--------------------------------------------------------------------------
  193.   def display_use_item(subject, item)
  194.     if item.is_a?(RPG::Skill)
  195.       if subject.is_a?(Game_Actor)
  196.         weapon = (subject.equips[0].id).to_i
  197.         wpn_name = $data_weapons[weapon].name
  198.         if item.id == 1
  199.           add_text(subject.name + " attacks with " + wpn_name)
  200.           unless item.message2.empty?
  201.             wait
  202.             add_text(item.message2)
  203.           end
  204.         else
  205.           add_text(subject.name + " uses " + item.name)
  206.           unless item.message2.empty?
  207.             wait
  208.             add_text(item.message2)
  209.           end
  210.         end
  211.       end
  212.     else
  213.       add_text(sprintf(Vocab::UseItem, subject.name, item.name))
  214.     end
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # * Display Skill/Item Use
  218.   #--------------------------------------------------------------------------
  219.   def defeat_enemy
  220.     add_text(" Defeated the enemy. ")
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # * Display Action Results
  224.   #--------------------------------------------------------------------------
  225.   def display_action_results(target, item)
  226.     if target.result.used
  227.       last_line_number = line_number
  228.       wait if line_number > last_line_number
  229.       back_to(last_line_number)
  230.     end
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # * Display Action Results
  234.   #--------------------------------------------------------------------------
  235.   def display_enemy_weakness(name, state, value1, value2)
  236.     strong = "strong"
  237.     weak = "weak"
  238.     value = ((value1 + value2) / 2)
  239.     if value != 1.00
  240.       defense = value > 1.00 ? weak : strong
  241.       state_name = $data_states[state].name
  242.       text = sprintf("%s is %s against %s attack", name, defense, state_name)
  243.       add_text(text)
  244.     end
  245.   end
  246. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement