Guest User

Untitled

a guest
Jun 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.92 KB | None | 0 0
  1. #======================================================================
  2. # Jens009's Enemy Hp Window
  3. # Version 1.2
  4. # Log: July 29, 2008
  5. # - Version 1.0: Show Enemy Hp Bars
  6. # August 5, 2008
  7. # - Version 1.1: Enable On/Off feature Using a $game_system instance
  8. # : Enable On/Off feature using an in-game switch
  9. # August 8, 2008
  10. # - Version 1.2: Add New Options
  11. # : Change Default Window Size
  12. # : Add Enemy States
  13. # Rant: [Code Geass ftw]
  14. # C.C. Still loves Pizza <3
  15. # Be nice to her Lulu.
  16. # Oh.. I haven't done my summer homework yet. T_T
  17. #
  18. # Credits to:
  19. # Jens009 (Translation and Modification)
  20. # Puppeto4 (Alias tutorial and for bugging me to create a script)
  21. # just kidding puppeto =p
  22. # Author's Note:
  23. # 9 Methods were aliased. Refer to lines 110-118
  24. # 4 Were not necessary but was needed so that Enemy Window
  25. # was not present during item/skill selections.
  26. #
  27. #
  28. # Modification:
  29. # If you want to modify the bars, look @lines 42-72.You can see that
  30. # I simply took draw_actor_hp and turned it into draw_enemy_hp
  31. # This means you can use any bars you desire so long as you define
  32. # it correctly. =]
  33. #
  34. #-----------------------------------------------------------------------------
  35. # CONFIG:
  36. #
  37. # I. Turning the Window On of Off during In-Game:
  38. #
  39. # There are two kinds of switches you can use depending
  40. # upon your liking. I made it so that you either have a
  41. # game switch or a script switch that handles the enemy window flag.
  42. #
  43. # If you want to use a script switch
  44. # -set USE_GSWITCH to false
  45. # -Use a call script, $game_system.enemy_window = true/false
  46. # True = Window Shows up, False = No Enemy Window
  47. #
  48. # If you want to use a game switch
  49. # -Set USE_GSWITCH to true
  50. # -Decide what Game Switch ID you want to use
  51. # in ENEMY_WINDOW_SWITCH
  52. # -Use that game switch to check for showing the Enemy Hp Window
  53. # True = Window Shows up, False = No enemy window.
  54. #
  55. #
  56. # BY DEFAULT, USE_GSWITCH is false.
  57. # So you are using a Script Switch
  58. #
  59. # II. ALWAYS_UPDATE
  60. # can either be set to true or false.
  61. # if true, the enemy window always update for every action
  62. # but the battle system will have more lag.
  63. # if false, the enemy window only updates at the end of each turn
  64. # and everytime the battle selection begins.
  65. # Setting it to false will lower compatibility but should still work
  66. # for most systems regardless.
  67. #
  68. # III. Spacing X and Y change
  69. # SPACING_X = Changing this number will change the X spacing of the windows
  70. # SPACING_Y = Changing this number will change the Y spacing of the windows
  71. # IV. COLUMNS
  72. # COLUMNS = Draw enemy information by creating 4 columns.
  73. # V. SHOW_STATES
  74. # if set to true, enemies state will be shown.
  75. #======================================================================
  76. module JCONFIG
  77. USE_GSWITCH = false # Setting it to false will use the script
  78. # switch $game_system.enemy_hp instead.
  79. # Setting it to true will use an in-game switch
  80. # using the switch ID below.
  81. ENEMY_WINDOW_SWITCH = 1 # Switch ID that will be used to check
  82. # Enemy Window is only ON, when Switch is ON
  83. ALWAYS_UPDATE = true # True = window always updates
  84. # False = window updates at end of turn
  85. SPACING_X = 90 # X spacing per enemy info
  86. SPACING_Y = 44 # Y spacing per enemy info
  87. COLUMNS = 4 # By default, Do 4 Columns.
  88. SHOW_STATES = true # true will show enemies states
  89. # false will not show states
  90.  
  91. end
  92.  
  93. #======================================================================
  94. # Start Game_System Edit
  95. #======================================================================
  96. class Game_System
  97. attr_accessor :enemy_hp # Show enemy HP on battle
  98.  
  99. alias jens009_system_initialize_enemy_hp initialize
  100. #=============================================
  101. # Initialize Values
  102. #=============================================
  103. def initialize
  104. # Initialize enemy hp window to true
  105. @enemy_hp = true
  106. # Call previous methods
  107. jens009_system_initialize_enemy_hp
  108. end
  109.  
  110. end # END Game system Edit
  111.  
  112.  
  113. class Window_Base
  114. #====================================
  115. # Define Enemy Name
  116. #====================================
  117. def draw_enemy_name(enemy, x, y)
  118. self.contents.font.color = normal_color
  119. self.contents.draw_text (x, y, 120, 32, enemy.name)
  120. end
  121.  
  122. #==========================
  123. # Define Enemy State
  124. #========================
  125. def draw_enemy_state(enemy, x, y)
  126. count = 0
  127. for state in enemy.states
  128. draw_icon(state.icon_index, x + 24 * count, y)
  129. count += 1
  130. break if (24 * count > width - 24)
  131. end
  132. end
  133. #--------------------------------------------------------------------------
  134. # * Draw Enemy HP
  135. # actor : actor
  136. # x : draw spot x-coordinate
  137. # y : draw spot y-coordinate
  138. # width : Width
  139. #--------------------------------------------------------------------------
  140. def draw_enemy_hp(enemy, x, y, width = 120)
  141. draw_enemy_hp_gauge(enemy, x, y, width)
  142. self.contents.font.color = system_color
  143. self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a)
  144. last_font_size = self.contents.font.size
  145. xr = x + width
  146. if width < 120
  147. self.contents.draw_text(xr - 44, y, 44, WLH, enemy.hp, 2)
  148. else
  149. self.contents.draw_text(xr - 99, y, 44, WLH, enemy.hp, 2)
  150. self.contents.font.color = normal_color
  151. self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
  152. self.contents.draw_text(xr - 44, y, 44, WLH, enemy.maxhp, 2)
  153. end
  154. end
  155. #--------------------------------------------------------------------------
  156. # * Draw HP gauge
  157. # actor : actor
  158. # x : draw spot x-coordinate
  159. # y : draw spot y-coordinate
  160. # width : Width
  161. #--------------------------------------------------------------------------
  162. def draw_enemy_hp_gauge(enemy, x, y, width = 120)
  163. gw = width * enemy.hp / enemy.maxhp
  164. gc1 = hp_gauge_color1
  165. gc2 = hp_gauge_color2
  166. self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
  167. self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
  168. end
  169.  
  170. end #End of Window_Base Class
  171.  
  172.  
  173. #=====================================#
  174. # Window_EnemyHP #
  175. # Class handles window for Enemy's HP #
  176. #=====================================#
  177. class Window_EnemyHP < Window_Selectable
  178. def initialize
  179. super ( 0, 0, 545, 300)
  180. self.contents = Bitmap.new(width - 32, height - 32)
  181. self.opacity = 0
  182. @column_max = JCONFIG::COLUMNS
  183. refresh
  184. end
  185.  
  186. def refresh
  187. self.contents.clear
  188. for i in 0...$game_troop.members.size
  189. enemy = $game_troop.members[i]
  190. x = i % @column_max * (JCONFIG::SPACING_X + @spacing)
  191. if JCONFIG::SHOW_STATES
  192. y = (i / @column_max * (JCONFIG::SPACING_Y + WLH) )
  193. else
  194. y = (i / @column_max * ((JCONFIG::SPACING_Y - 34) + WLH) )
  195. end
  196.  
  197. #========================================
  198. # If Using Game_Switch
  199. #=========================================
  200. if JCONFIG::USE_GSWITCH and $game_switches[JCONFIG::ENEMY_WINDOW_SWITCH]
  201. draw_enemy_hp(enemy, x, y+20, 90)
  202. draw_enemy_name(enemy, x, y)
  203. if JCONFIG::SHOW_STATES
  204. draw_enemy_state(enemy, x, y +44)
  205. end
  206. end
  207. #==========================================
  208. # If Using Script Switch
  209. #==========================================
  210. if JCONFIG::USE_GSWITCH == false
  211. if $game_system.enemy_hp == true # Start check if Window Flag is On
  212. draw_enemy_hp(enemy, x, y+20, 90)
  213. draw_enemy_name(enemy, x, y)
  214. if JCONFIG::SHOW_STATES
  215. draw_enemy_state(enemy, x, y +44)
  216. end # END CHECK
  217. end #End flag check
  218. end # END game switche check
  219.  
  220. end
  221. end #End Refresh
  222.  
  223. end #End of Window_EnemyHP Class
  224.  
  225.  
  226. #====================================#
  227. # Scene_Battle #
  228. # New methods that were aliased: #
  229. #====================================#
  230. class Scene_Battle
  231.  
  232. alias jens009_create_info_viewport create_info_viewport
  233. alias jens009_dispose_info_viewport dispose_info_viewport
  234. alias jens009_start_item_selection start_item_selection
  235. alias jens009_start_skill_selection start_skill_selection
  236. alias jens009_end_item_selection end_item_selection
  237. alias jens009_end_skill_selection end_skill_selection
  238. alias jens009_process_victory process_victory
  239.  
  240. alias jens009_update_info_viewport update_info_viewport
  241.  
  242. alias jens009_start_party_command_selection start_party_command_selection
  243. alias jens009_execute_action execute_action
  244. alias jens009_turn_end turn_end
  245.  
  246. # Create Information
  247. def create_info_viewport
  248. jens009_create_info_viewport
  249. @enemy_window = Window_EnemyHP.new
  250. end
  251. # Dispose Information
  252. def dispose_info_viewport
  253. jens009_dispose_info_viewport
  254. @enemy_window.dispose
  255. end
  256.  
  257. #=============================================
  258. # Always Update Window
  259. #============================================
  260. def update_info_viewport
  261. if JCONFIG::ALWAYS_UPDATE == true
  262. @enemy_window.refresh
  263. jens009_update_info_viewport
  264. else
  265. jens009_update_info_viewport
  266. end
  267. end
  268.  
  269. #=============================================
  270. # Update Only When Turn starts and ends
  271. #============================================
  272. def start_party_command_selection
  273. if JCONFIG::ALWAYS_UPDATE == true
  274. jens009_start_party_command_selection
  275. else
  276. @enemy_window.visible = true
  277. @enemy_window.refresh
  278. jens009_start_party_command_selection
  279. end
  280. end
  281.  
  282. def execute_action
  283. if JCONFIG::ALWAYS_UPDATE == true
  284. jens009_execute_action
  285. else
  286. @enemy_window.visible = false
  287. jens009_execute_action
  288. end
  289. end
  290.  
  291. def turn_end
  292. if JCONFIG::ALWAYS_UPDATE == true
  293. jens009_turn_end
  294. else
  295. @enemy_window.refresh
  296. jens009_turn_end
  297. end
  298. end
  299. #============================================
  300. # END OF UPDATE CHECK
  301. #===========================================
  302.  
  303. #=====================================
  304. # Remove Window During Selection
  305. def start_item_selection
  306. @enemy_window.visible = false
  307. jens009_start_item_selection
  308. end
  309. # Remove Window During Selection
  310. def start_skill_selection
  311. @enemy_window.visible = false
  312. jens009_start_skill_selection
  313. end
  314. # True Visibility after slection
  315. def end_item_selection
  316. jens009_end_item_selection
  317. @enemy_window.visible = true
  318. end
  319. # True Visibility after selection
  320. def end_skill_selection
  321. jens009_end_skill_selection
  322. @enemy_window.visible = true
  323. end
  324. # Refresh When Victorious
  325. def process_victory
  326. @enemy_window.refresh
  327. jens009_process_victory
  328. end
  329.  
  330. #=====================================#
  331. # End of Scene_Battle Method Edits #
  332. #=====================================#
  333.  
  334. end
Add Comment
Please, Sign In to add comment