Advertisement
Double_X

Log Window Display

Jun 16th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.59 KB | None | 0 0
  1. #------------------------------------------------------------------------------|
  2. #  * Edit class: Window_BattleLog                                              |
  3. #------------------------------------------------------------------------------|
  4.  
  5. class Window_BattleLog < Window_Selectable
  6.  
  7. #==============================================================================|
  8. #  ** You only need to edit this part as it's about what this snippet does     |
  9. #------------------------------------------------------------------------------|
  10.  
  11.   #----------------------------------------------------------------------------|
  12.   #  New constant                                                              |
  13.   #----------------------------------------------------------------------------|
  14.   # Sets the maximum number of lines displayed by the battle log simultaneously
  15.   MAX_LINE_NUMBER = 6
  16.  
  17. #==============================================================================|
  18.  
  19. #==============================================================================|
  20. #  ** You need not edit this part as it's about how this snippet works         |
  21. #------------------------------------------------------------------------------|
  22.  
  23.   #----------------------------------------------------------------------------|
  24.   #  New public instance variables                                             |
  25.   #----------------------------------------------------------------------------|
  26.   attr_writer :executing_action
  27.   attr_writer :last_line_number
  28.  
  29.   #----------------------------------------------------------------------------|
  30.   #  Rewrite method: max_line_number                                           |
  31.   #----------------------------------------------------------------------------|
  32.   def max_line_number
  33.     # Rewritten to use the constant set by the users
  34.     MAX_LINE_NUMBER
  35.     #
  36.   end # max_line_number
  37.  
  38.   #----------------------------------------------------------------------------|
  39.   #  Rewrite method: display_counter                                           |
  40.   #----------------------------------------------------------------------------|
  41.   def display_counter(target, item)
  42.     # Rewritten to show all logs until the max line number's reached
  43.     @last_line_number ||= line_number
  44.     Sound.play_evasion
  45.     add_text(sprintf(Vocab::CounterAttack, target.name))
  46.     process_max_line_number_breach(item) if line_number >= max_line_number
  47.     #
  48.   end # display_counter
  49.  
  50.   #----------------------------------------------------------------------------|
  51.   #  Rewrite method: display_reflection                                        |
  52.   #----------------------------------------------------------------------------|
  53.   def display_reflection(target, item)
  54.     # Rewritten to show all logs until the max line number's reached
  55.     @last_line_number ||= line_number
  56.     Sound.play_reflection
  57.     add_text(sprintf(Vocab::MagicReflection, target.name))
  58.     process_max_line_number_breach(item) if line_number >= max_line_number
  59.     #
  60.   end # display_reflection
  61.  
  62.   #----------------------------------------------------------------------------|
  63.   #  Rewrite method: display_substitute                                        |
  64.   #----------------------------------------------------------------------------|
  65.   def display_substitute(substitute, target)
  66.     # Rewritten to show all logs until the max line number's reached
  67.     @last_line_number ||= line_number
  68.     add_text(sprintf(Vocab::Substitute, substitute.name, target.name))
  69.     process_max_line_number_breach(item) if line_number >= max_line_number
  70.     #
  71.   end # display_substitute
  72.  
  73.   #----------------------------------------------------------------------------|
  74.   #  Rewrite method: display_action_results                                    |
  75.   #----------------------------------------------------------------------------|
  76.   def display_action_results(target, item)
  77.     # Rewritten to show all logs until the max line number's reached
  78.     @last_line_number ||= line_number
  79.     @wait = !item.for_all? && target.alive?
  80.     if target.result.used
  81.       [:display_critical, :display_damage, :display_affected_status,
  82.        :display_failure].each{ |method|
  83.         send(method, target,item)
  84.         process_max_line_number_breach(item) if line_number >= max_line_number
  85.       }
  86.     end
  87.     @wait = true
  88.     #
  89.   end # display_action_results
  90.  
  91.   #----------------------------------------------------------------------------|
  92.   #  Rewrite method: display_added_states                                      |
  93.   #----------------------------------------------------------------------------|
  94.   def display_added_states(target)
  95.     target.result.added_state_objects.each do |state|
  96.       state_msg = target.actor? ? state.message1 : state.message2
  97.       # Rewritten to stop collapsing targets while executing an action
  98.       unless @executing_action || state.id != target.death_state_id
  99.         target.perform_collapse_effect
  100.       end
  101.       #
  102.       next if state_msg.empty?
  103.       replace_text(target.name + state_msg)
  104.       wait
  105.       wait_for_effect
  106.     end
  107.   end # display_added_states
  108.  
  109.   #----------------------------------------------------------------------------|
  110.   #  Alias method: wait                                                        |
  111.   #----------------------------------------------------------------------------|
  112.   alias wait_log_window_display wait
  113.   def wait
  114.     # Rewritten to wait only when asked by this snippet
  115.     wait_log_window_display if @wait
  116.     #
  117.   end # wait
  118.  
  119.   #----------------------------------------------------------------------------|
  120.   #  Alias method: wait_for_effect                                             |
  121.   #----------------------------------------------------------------------------|
  122.   alias wait_for_effect_log_window_display wait
  123.   def wait_for_effect
  124.     # Rewritten to wait for effect only when asked by this snippet
  125.     wait_for_effect_log_window_display if @wait
  126.     #
  127.   end # wait_for_effect
  128.  
  129.   #----------------------------------------------------------------------------|
  130.   #  New method: process_max_line_number_breach                                |
  131.   #  - Clears the displayed lines when the maximum line number's reached       |
  132.   #----------------------------------------------------------------------------|
  133.   def process_max_line_number_breach(item)
  134.     # Has a short wait before clearing the currently displayed lines
  135.     @wait = true
  136.     wait
  137.     wait if item.for_all?
  138.     @wait = !item.for_all?
  139.     back_to(@last_line_number)
  140.     @last_line_number = line_number
  141.     #
  142.   end # process_max_line_number_breach
  143.  
  144. end # Window_BattleLog
  145.  
  146. #------------------------------------------------------------------------------|
  147. #  * Edit class: Scene_Battle                                                  |
  148. #------------------------------------------------------------------------------|
  149.  
  150. class Scene_Battle < Scene_Base
  151.  
  152.   #----------------------------------------------------------------------------|
  153.   #  Rewrite method: apply_item_effects                                        |
  154.   #----------------------------------------------------------------------------|
  155.   def apply_item_effects(target, item)
  156.     target.item_apply(@subject, item)
  157.     # Rewritten to refresh the status window only if the target's an actor
  158.     @status_window.refresh if target.actor? && target.index >= 0
  159.     #
  160.     @log_window.display_action_results(target, item)
  161.     # Added to have short waits between applications for single target items
  162.     @log_window.wait if item.for_one? && target.alive?
  163.     #
  164.   end # apply_item_effects
  165.  
  166.   #----------------------------------------------------------------------------|
  167.   #  Rewrite method: invoke_counter_attack                                     |
  168.   #----------------------------------------------------------------------------|
  169.   def invoke_counter_attack(target, item)
  170.     @log_window.display_counter(target, item)
  171.     attack_skill = $data_skills[target.attack_skill_id]
  172.     @subject.item_apply(target, attack_skill)
  173.     # Rewritten to refresh the status window only if the target's an actor
  174.     @status_window.refresh if @subject.actor? && @subject.index >= 0
  175.     #
  176.     @log_window.display_action_results(@subject, attack_skill)
  177.     # Added to have short waits between applications for single target items
  178.     @log_window.wait if item.for_one? && @subject.alive?
  179.     #
  180.   end # invoke_counter_attack
  181.  
  182.   #----------------------------------------------------------------------------|
  183.   #  Alias method: use_item                                                    |
  184.   #----------------------------------------------------------------------------|
  185.   alias use_item_log_window_display use_item
  186.   def use_item
  187.     # Added to store all alive battlers
  188.     alive_battle_members = $game_party.alive_members + $game_troop.alive_members
  189.     #
  190.     # Added to tell the log window that an action begins to execute
  191.     @log_window.executing_action = true
  192.     @log_window.last_line_number = nil
  193.     #
  194.     use_item_log_window_display
  195.     # Added to tell the log window that an action finishes its execution
  196.     @log_window.executing_action = false
  197.     @log_window.last_line_number = nil
  198.     #
  199.     # Added to collapse all previously alive battlers that are now dead
  200.     return unless alive_battle_members.any? { |member| member.dead? }
  201.     @log_window.wait_log_window_display
  202.     alive_battle_members.each { |m| m.perform_collapse_effect if m.dead? }
  203.     3.times { @log_window.wait_log_window_display }
  204.     #
  205.   end # use_item
  206.  
  207. end # Scene_Battle
  208.  
  209. #==============================================================================|
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement