Advertisement
neutale

Turn Window

Mar 27th, 2018
1,222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.90 KB | None | 0 0
  1. #==============================================================================
  2. # ★ RGSS3_TurnWindowDisplayforBattle Ver1.01
  3. #==============================================================================
  4. =begin
  5.  
  6.   Author:ぷり娘 (prico)
  7. web site:Sister's Eternal 4th(Ancient)
  8.      URL:http://pricono.whitesnow.jp/
  9. Permission to use: Not required, but please mention in the game, Readme, etc.
  10.  
  11. Displays the current amount of turns on the battle screen.
  12. The number of turns is displayed up to 3 digits (limit 999 turns)
  13.  
  14. By default, it'll appear in semi-transparent window.
  15. Position of Turn Window can be change through script setting.
  16.  
  17. Also, it will hidden during battle events.
  18.  
  19.  
  20.  
  21. 2012.06.21 Ver1.00 Public release
  22. 2012.06.23 Ver1.01 Fixed a bug where an enemy action does not match # turn display.
  23.  
  24. =end
  25.  
  26.  
  27. #==============================================================================
  28. # Setting
  29. #==============================================================================
  30. module Prico
  31.  
  32.   #X coordinate of Turn Window
  33.   WindowX = 440
  34.  
  35.   #Y coordinate of Turn Window
  36.   WindowY = 0
  37.  
  38.   #Turn Window width
  39.   WindowW = 104
  40.  
  41. end
  42.  
  43.  
  44.  
  45. #==============================================================================
  46. # ■ BattleManager
  47. #------------------------------------------------------------------------------
  48. #  Module that manages the battle progress
  49. #==============================================================================
  50. module BattleManager
  51.   #--------------------------------------------------------------------------
  52.   # ● Turn start(redefinition, just delete $game_troop.increase_turn)
  53.   #--------------------------------------------------------------------------
  54.   def self.turn_start
  55.     @phase = :turn
  56.     clear_actor
  57.     make_action_orders
  58.   end
  59.  
  60.   #--------------------------------------------------------------------------
  61.   # ● Command input start(redefinition, just delete $game_troop.make_actions)
  62.   #--------------------------------------------------------------------------
  63.   def self.input_start
  64.     if @phase != :input
  65.       @phase = :input
  66.       $game_party.make_actions
  67.       clear_actor
  68.     end
  69.     return !@surprise && $game_party.inputable?
  70.   end
  71.  
  72. end
  73.  
  74.  
  75. #==============================================================================
  76. # ■ Scene_Battle
  77. #------------------------------------------------------------------------------
  78. #  Class that performs battle screen processing
  79. #==============================================================================
  80. class Scene_Battle < Scene_Base
  81.   #--------------------------------------------------------------------------
  82.   # ● Create all windows(alias)
  83.   #--------------------------------------------------------------------------
  84.   alias create_all_windows_org create_all_windows
  85.   def create_all_windows
  86.     create_all_windows_org
  87.     create_turn_window
  88.   end
  89.  
  90.   #--------------------------------------------------------------------------
  91.   # ● Creating turn number window(new)
  92.   #--------------------------------------------------------------------------
  93.   def create_turn_window
  94.     @turn_window = Window_Turn.new
  95.     @turn_window.visible = false
  96.   end
  97.  
  98.   #--------------------------------------------------------------------------
  99.   # ● Battle start(alias)
  100.   #--------------------------------------------------------------------------
  101.   alias battle_start_org battle_start
  102.   def battle_start
  103.     battle_start_org
  104.     $game_troop.increase_turn
  105.     $game_troop.make_actions
  106.     @turn_window.opacity = 127
  107.     @turn_window.visible = true
  108.     @turn_window.refresh
  109.   end
  110.  
  111.   #--------------------------------------------------------------------------
  112.   # ● Turn start(alias)
  113.   #--------------------------------------------------------------------------
  114.   alias turn_start_org turn_start
  115.   def turn_start
  116.     turn_start_org
  117.     @turn_window.visible = true
  118.     @turn_window.refresh
  119.   end
  120.  
  121.   #--------------------------------------------------------------------------
  122.   # ● Turn end(alias)
  123.   #--------------------------------------------------------------------------
  124.   alias turn_end_org turn_end
  125.   def turn_end
  126.     turn_end_org
  127.     $game_troop.increase_turn
  128.     $game_troop.make_actions
  129.     @turn_window.visible = true
  130.     @turn_window.refresh
  131.   end
  132.  
  133.   #--------------------------------------------------------------------------
  134.   # ● Event processing(redefinition)
  135.   #--------------------------------------------------------------------------
  136.   def process_event
  137.     while !scene_changing?
  138.       @turn_window.visible = false if $game_troop.interpreter.running?
  139.       $game_troop.interpreter.update
  140.       $game_troop.setup_battle_event
  141.       wait_for_message
  142.       wait_for_effect if $game_troop.all_dead?
  143.       process_forced_action
  144.       BattleManager.judge_win_loss
  145.       break unless $game_troop.interpreter.running?
  146.       update_for_wait
  147.     end
  148.   end
  149. end
  150.  
  151.  
  152. #==============================================================================
  153. # ■ Window_Turn
  154. #   Window that displays the current number of turns
  155. #==============================================================================
  156. class Window_Turn < Window_Base
  157.   #--------------------------------------------------------------------------
  158.   # ● Object initialization
  159.   #--------------------------------------------------------------------------
  160.   def initialize
  161.     super(Prico::WindowX,Prico::WindowY,Prico::WindowW,line_height * 2)
  162.     self.contents = Bitmap.new(self.width - 24, self.height - 28)
  163.     refresh
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● Refresh
  167.   #--------------------------------------------------------------------------
  168.   def refresh
  169.     self.contents.clear
  170.     self.contents.font.size = 23
  171.     @text = sprintf("%03d %s",$game_troop.turn_count,"TURN")
  172.     draw_text_ex(0, 0, @text)
  173.     reset_font_settings
  174.   end
  175. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement