pigu_6

Saba kan| HP bar

Nov 24th, 2012
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. #==============================================================================
  2. # ■ 世界樹の迷宮っぽい敵選択カーソル
  3. # @version 0.3 2012/09/19
  4. # @author さば缶
  5. #------------------------------------------------------------------------------
  6. # ※ Graphics/System フォルダの画像が必要です。
  7. #==============================================================================
  8.  
  9. module Saba
  10. module Sekaiju3
  11. # ヘルプウィンドウのサイズ
  12. HELP_WINDOW_WIDTH = 544
  13.  
  14. # 敵選択カーソルの座標。敵の座標からの相対値
  15. CURSOR_X = -65
  16. CURSOR_Y = 90
  17.  
  18. # 敵選択カーソル内でのHPバーの座標と長さ
  19. GAUGE_X = 30
  20. GAUGE_Y = -8
  21. GAUGE_WIDTH = 73
  22.  
  23. # カーソルのY座標も敵の座標にあわせる場合 true
  24. ADJUST_Y = false
  25. # カーソルの最小Y座標
  26. CURSOR_MIN_Y = 50
  27. #CURSOR_Y = -70 # ADJUST_Yを trueのときはこのあたりの数値で
  28.  
  29. # 敵のHPを表示しない場合 true に設定します
  30. HIDE_ENEMY_HP = false
  31. end
  32. end
  33.  
  34.  
  35. class Scene_Battle
  36. #--------------------------------------------------------------------------
  37. # ● 敵キャラ選択の開始
  38. #--------------------------------------------------------------------------
  39. alias saba_sekaiju3_select_enemy_selection select_enemy_selection
  40. def select_enemy_selection
  41. @item_window.hide
  42. @skill_window.hide
  43. saba_sekaiju3_select_enemy_selection
  44. end
  45. #--------------------------------------------------------------------------
  46. # ● 敵キャラ[キャンセル]
  47. #--------------------------------------------------------------------------
  48. alias saba_sekaiju3_on_enemy_cancel on_enemy_cancel
  49. def on_enemy_cancel
  50. case @actor_command_window.current_symbol
  51. when :attack
  52. @actor_command_window.show
  53. when :skill
  54. @skill_window.show
  55. when :item
  56. @item_window.show
  57. end
  58. saba_sekaiju3_on_enemy_cancel
  59. end
  60. end
  61.  
  62. class Window_BattleEnemy < Window_Selectable
  63. include Saba::Sekaiju3
  64. #--------------------------------------------------------------------------
  65. # ● オブジェクト初期化
  66. # info_viewport : 情報表示用ビューポート
  67. #--------------------------------------------------------------------------
  68. def initialize(info_viewport)
  69. super(0, 0, window_width, window_height)
  70. refresh
  71. self.visible = false
  72. self.opacity = 0
  73. @help_window = Window_Help.new(1)
  74. @help_window.width = HELP_WINDOW_WIDTH
  75. @help_window.x = (Graphics.width - HELP_WINDOW_WIDTH) / 2
  76. @help_window.create_contents
  77. @help_window.hide
  78. end
  79. #--------------------------------------------------------------------------
  80. # ● 解放
  81. #--------------------------------------------------------------------------
  82. def dispose
  83. super
  84. @help_window.dispose
  85. end
  86. #--------------------------------------------------------------------------
  87. # ● ウィンドウ幅の取得
  88. #--------------------------------------------------------------------------
  89. def window_width
  90. Graphics.width
  91. end
  92. #--------------------------------------------------------------------------
  93. # ● ウィンドウ高さの取得
  94. #--------------------------------------------------------------------------
  95. def window_height
  96. Graphics.height
  97. end
  98. def row_max
  99. return $game_troop.alive_members.size
  100. end
  101. #--------------------------------------------------------------------------
  102. # ● ウィンドウのアクティブ化
  103. #--------------------------------------------------------------------------
  104. def activate
  105. super
  106. select(0)
  107. cursor_rect.empty
  108. call_update_help
  109. return self
  110. end
  111. #--------------------------------------------------------------------------
  112. # ● リフレッシュ
  113. #--------------------------------------------------------------------------
  114. def refresh
  115. cursor_rect.empty
  116. enemy = selected_enemy
  117. self.contents.clear
  118. if ADJUST_Y
  119. y = enemy.screen_y + CURSOR_Y - Cache.battler(enemy.battler_name, enemy.battler_hue).height
  120. y = [y, CURSOR_MIN_Y].max
  121. else
  122. y = CURSOR_Y
  123. end
  124. if HIDE_ENEMY_HP
  125. img = Cache.system("enemy_cursor2")
  126. self.contents.blt(enemy.screen_x + CURSOR_X, y, img, img.rect)
  127. else
  128. img = Cache.system("enemy_cursor")
  129. self.contents.blt(enemy.screen_x + CURSOR_X, y, img, img.rect)
  130. draw_gauge(enemy.screen_x + CURSOR_X + GAUGE_X, y + GAUGE_Y, GAUGE_WIDTH, enemy.hp_rate, hp_gauge_color1, hp_gauge_color2)
  131. end
  132. end
  133. #--------------------------------------------------------------------------
  134. # ● 項目の選択
  135. #--------------------------------------------------------------------------
  136. def select(index)
  137. self.index = index
  138. refresh
  139. call_update_help
  140. call_handler(:change)
  141. end
  142. #--------------------------------------------------------------------------
  143. # ● 項目の描画
  144. #--------------------------------------------------------------------------
  145. def draw_item(index)
  146. # 何もしない
  147. end
  148. #--------------------------------------------------------------------------
  149. # ● ウィンドウの非表示
  150. #--------------------------------------------------------------------------
  151. def hide
  152. super
  153. @help_window.hide
  154. end
  155. #--------------------------------------------------------------------------
  156. # ○ 選択されている敵の取得
  157. #--------------------------------------------------------------------------
  158. def selected_enemy
  159. e = $game_troop.alive_members[self.index]
  160. return e if e
  161. self.index = 0
  162. $game_troop.alive_members[self.index]
  163. end
  164. #--------------------------------------------------------------------------
  165. # ● ヘルプウィンドウの更新
  166. #--------------------------------------------------------------------------
  167. def update_help
  168. @help_window.clear
  169. @help_window.set_text(selected_enemy.name)
  170. @help_window.show
  171. end
  172. end
Advertisement
Add Comment
Please, Sign In to add comment