Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #===============================================================================
  2. # * Falcao Pearl ABS script shelf # 7
  3. #
  4. # Actor / Eenemies HP and MP bars display v 2.0
  5. #
  6. # This script acts like an Add-On, the main system can run without this piece
  7. #
  8. #-------------------------------------------------------------------------------
  9.  
  10. # * Features
  11. # - Display HP, MP, experience and TP bars of the current player actor
  12. # - Display the Enemy HP bar when was hit
  13. # - Boss HP bar anabled
  14. # - Display enemy states and buff / debuff icons
  15. # - Non-graphical bars but hightly customizable
  16. # - 2.0 now support images instead of script drawing bars
  17.  
  18. # * Usage and Installation
  19. # Just copy and paste below the Pearl ABS System
  20. #
  21. # * Commands
  22. # PearlBars.hide - Hide the actor bars
  23. # PearlBars.show - Show the actor bars (by default)
  24. #
  25. # PearlBars.enemy_auto(id)- Show automatically the enemy HP bars without need
  26. # to hit, this is mostly used for bosses, change id for the event id
  27. # Tag any enemy with Enemy Boss Bar = true to eneble the boss bar mode
  28. #------------------------------------------------------------------------------
  29. module PearlBars
  30. #=============================================================================
  31. # * Actors bars configuration
  32. #
  33. # Bars x and y position on the screen
  34. ScreenPos_X = 430
  35. ScreenPos_Y = 5
  36. #
  37. # Dimentions of the bars you cant exceed 300 width x 100 height
  38. # x y width height
  39. HP_BarDimentions = [8, 16, 118, 14]
  40. MP_BarDimentions = [8, 36, 118, 14]
  41. EX_BarDimentions = [8, 57, 118, 10]
  42.  
  43. # Tp info x y
  44. TP_Info = [500, 500]
  45. #
  46. # color definition
  47. # color 1 R G B Opa color 2 R G B Opa
  48. HP_Color = [Color.new(205, 255, 205, 100), Color.new(10, 220, 45, 100)]
  49. MP_Color = [Color.new(180, 225, 245, 100), Color.new(20, 160, 225, 100)]
  50. EX_Color = [Color.new(180, 225, 245, 100), Color.new(20, 160, 225, 100)]
  51.  
  52. # Do you want to display graphics instead of script drawing bars?
  53. # if so, fill this actors bars graphics requirements
  54.  
  55. ActorsHp = "Actors_HP" # Actor Hp graphic bar name (inside quotation marks)
  56. ActorsMp = "Actors_MP" # Actor Mp graphic bar name
  57. ActorsExp = "Actors_Back" # Actor Experience, if you dont want it leave it ""
  58. ActorsExp = "Actors_EX" # Actor Experience, if you dont want it leave
  59. ActorsBack = "Actors_Back" # Background semi-transparent bar
  60.  
  61. #=============================================================================
  62. # * Normal Enemies bars
  63. #
  64. # Normal enemies Bars x and y position on the screen
  65. NeScreenPos_X = 0
  66. NeScreenPos_Y = 0
  67. #
  68. # Dimentions of the bars you cant exceed 300 width x 100 height
  69. # x y width height
  70. EHP_BarDimentions = [8, 16, 126, 10]
  71. #
  72. # color definition
  73. # color 1 R G B Opa color 2 R G B Opa
  74. EHP_Color = [Color.new(205, 255, 205, 200), Color.new(10, 220, 45, 200)]
  75.  
  76. # if you want to display grahics bar pictures fill this
  77. NormalEne = "Actors_Hp" # normal enemy hp bar
  78. NormalBack = "Actors_Back" # Background semi-transparent bar
  79.  
  80. #=============================================================================
  81. # * Enemy Boss HP Bar
  82. #
  83. # Boss enemies Bar x and y position on the screen
  84. BeScreenPos_X = 100
  85. BeScreenPos_Y = 286
  86. #
  87. # Dimentions of the bars you cant exceed 640 width x 100 height
  88. # x y width height
  89. BHP_BarDimentions = [8, 22, 330, 12]
  90. #
  91. # color 1 R G B Opa color 2 R G B Opa
  92. BHP_Color = [Color.new(205, 255, 205, 200), Color.new(10, 220, 45, 200)]
  93.  
  94. # if you want to display grahics bar pictures fill this
  95. BossEne = "Actors_Back" # Boss enemy Hp bar
  96. BossBack = "Actors_Back" # Background semi-transparent bar
  97. #=============================================================================
  98.  
  99. def self.show() $game_system.pearlbars = nil end
  100. def self.hide() $game_system.pearlbars = true end
  101.  
  102. def self.enemy_auto(event_id)
  103. $game_system.enemy_lifeobject = $game_map.events[event_id]
  104. end
  105.  
  106. end
  107.  
  108. ($imported ||= {})["Falcao Pearl ABS Life"] = true
  109.  
  110. class Spriteset_Map
  111.  
  112. alias falcaopearl_lifebars_create create_pictures
  113. def create_pictures
  114. create_hud_lifebars
  115. falcaopearl_lifebars_create
  116. end
  117.  
  118. def create_hud_lifebars
  119. @enemy_lifeobject = $game_system.enemy_lifeobject
  120. @enemyhpsp = Sprite_LifeBars.new(@viewport2, @enemy_lifeobject) if
  121. not @enemy_lifeobject.nil?
  122. end
  123.  
  124. def create_actorlifebars
  125. return if !@actor_lifebar.nil?
  126. @actor_lifebar = Sprite_LifeBars.new(@viewport2, $game_player)
  127. end
  128.  
  129. def dispose_actorlifebars
  130. return if @actor_lifebar.nil?
  131. @actor_lifebar.dispose
  132. @actor_lifebar = nil
  133. end
  134.  
  135. alias falcaopearl_lifebars_update update
  136. def update
  137. update_lifebars_sprites
  138. falcaopearl_lifebars_update
  139. end
  140.  
  141. def update_lifebars_sprites
  142. $game_system.pearlbars.nil? ? create_actorlifebars : dispose_actorlifebars
  143. @actor_lifebar.update unless @actor_lifebar.nil?
  144.  
  145. # enemy
  146. if !@enemyhpsp.nil?
  147. unless @enemyhpsp.disposed?
  148. @enemyhpsp.update
  149. else
  150. @enemyhpsp.dispose
  151. @enemyhpsp = nil
  152. $game_system.enemy_lifeobject = nil
  153. @enemy_lifeobject = nil
  154. end
  155. end
  156.  
  157. if @enemy_lifeobject != $game_system.enemy_lifeobject
  158. @enemyhpsp.dispose if !@enemyhpsp.nil?
  159. @enemyhpsp = nil
  160. @enemyhpsp = Sprite_LifeBars.new(@viewport2,$game_system.enemy_lifeobject)
  161. @enemy_lifeobject = $game_system.enemy_lifeobject
  162. end
  163. end
  164.  
  165. alias falcaopearl_lifebars_dispose dispose
  166. def dispose
  167. dispose_actorlifebars
  168. @enemyhpsp.dispose unless @enemyhpsp.nil?
  169. falcaopearl_lifebars_dispose
  170. end
  171. end
  172.  
  173. # Life bars sprite
  174. class Sprite_LifeBars < Sprite
  175. include PearlBars
  176. def initialize(viewport, character)
  177. super(viewport)
  178. @character = character
  179. self.bitmap = Bitmap.new(boss? ? 640 : 300, 120)
  180. @old_hp = battler.hp
  181. @old_mp = battler.mp
  182. @erasetimer = 180
  183. @state_checker = []
  184. @buff_checker = []
  185. refresh_contents
  186. @view = viewport
  187. update
  188. end
  189.  
  190. def boss?
  191. return true if battler.is_a?(Game_Enemy) && battler.boss_hud
  192. return false
  193. end
  194.  
  195. def battler
  196. return @character.battler
  197. end
  198.  
  199. def refresh_contents
  200. self.bitmap.clear
  201. self.bitmap.font.size = 19
  202. @erasetimer = 180
  203. self.opacity = 255
  204. if battler.is_a?(Game_Actor)
  205. @old_exp = battler.exp
  206. @old_tp = battler.tp
  207. self.x = ScreenPos_X
  208. self.y = ScreenPos_Y
  209. h = HP_BarDimentions ; m = MP_BarDimentions ; e = EX_BarDimentions
  210. if PearlBars::ActorsHp != ""
  211. @pimg = Cache.picture(PearlBars::ActorsHp) if @pimg.nil?
  212. @bimg = Cache.picture(PearlBars::ActorsBack) if @bimg.nil?
  213. @pimp = Cache.picture(PearlBars::ActorsMp) if @pimp.nil?
  214. PearlKernel.image_hp(self.bitmap, h[0] + 4, h[1],@bimg,
  215. @pimg, battler,true)
  216. PearlKernel.image_mp(self.bitmap, m[0] + 4, m[1], @bimg, @pimp, battler)
  217. if PearlBars::ActorsExp != ""
  218. @piexp = Cache.picture(PearlBars::ActorsExp) if @piexp.nil?
  219. PearlKernel.image_exp(self.bitmap,e[0] + 4,e[1],@bimg,@piexp, battler)
  220. end
  221. else
  222. hc = HP_Color ; mc = MP_Color ; ec = EX_Color
  223. PearlKernel.draw_hp(self.bitmap,battler, h[0], h[1], h[2], h[3], hc)
  224. PearlKernel.draw_mp(self.bitmap,battler, m[0], m[1], m[2], m[3], mc)
  225. PearlKernel.draw_exp(self.bitmap,battler, e[0], e[1], e[2], e[3], ec)
  226. end
  227. PearlKernel.draw_tp(self.bitmap, TP_Info[0], TP_Info[1], battler)
  228. else battler.is_a?(Game_Enemy)
  229. if boss?
  230. self.x = BeScreenPos_X
  231. self.y = BeScreenPos_Y
  232. h = BHP_BarDimentions ; hc = BHP_Color
  233. if PearlBars::BossEne != ""
  234. @n_img = Cache.picture(PearlBars::BossEne) if @n_img.nil?
  235. @n_back = Cache.picture(PearlBars::BossBack) if @n_back.nil?
  236. PearlKernel.image_hp(self.bitmap, h[0] + 4, h[1],@n_back,
  237. @n_img, battler,true)
  238. else
  239. PearlKernel.draw_hp(self.bitmap,battler, h[0],h[1],h[2], h[3],hc,true)
  240. end
  241. else
  242. self.x = NeScreenPos_X
  243. self.y = NeScreenPos_Y
  244. h = EHP_BarDimentions ; hc = EHP_Color
  245. if PearlBars::NormalEne != ""
  246. @n_img = Cache.picture(PearlBars::NormalEne) if @n_img.nil?
  247. @n_back = Cache.picture(PearlBars::NormalBack) if @n_back.nil?
  248. PearlKernel.image_hp(self.bitmap, h[0] + 4, h[1],@n_back,
  249. @n_img, battler,true)
  250. else
  251. PearlKernel.draw_hp(self.bitmap,battler,h[0],h[1],h[2], h[3], hc,true)
  252. end
  253. end
  254. end
  255. end
  256.  
  257. def update
  258. super
  259.  
  260.  
  261. if battler.nil?
  262. dispose
  263. return
  264. end
  265.  
  266. if @old_hp != battler.hp
  267. refresh_contents
  268. @old_hp = battler.hp
  269. end
  270. if @old_mp != battler.mp
  271. refresh_contents
  272. @character.actor.apply_usability if @character.is_a?(Game_Player)
  273. @old_mp = battler.mp
  274. end
  275.  
  276. if battler.is_a?(Game_Actor)
  277. if @old_exp != battler.exp
  278. @old_exp = battler.exp
  279. refresh_contents
  280. end
  281.  
  282. if @old_tp != battler.tp
  283. @old_tp = battler.tp
  284. @character.actor.apply_usability if @character.is_a?(Game_Player)
  285. refresh_contents
  286. end
  287.  
  288. elsif battler.is_a?(Game_Enemy)
  289. if boss?
  290. dispose if battler.dead?
  291. else
  292. if @erasetimer > 0
  293. @erasetimer -= 1
  294. self.opacity -= 10 if @erasetimer <= 25
  295. @states.opacity = self.opacity if !@states.nil?
  296. dispose if @erasetimer == 0
  297. end
  298. end
  299. update_enemy_status_icons
  300. end
  301. end
  302.  
  303. # enemy status icons engine
  304. def update_enemy_status_icons
  305. display_status? ? create_states_icons : dispose_state_icons
  306. 4.times.each {|i| refresh_states_icons if
  307. @state_checker[i] != battler.state_icons[i]}
  308. 2.times.each {|i| refresh_states_icons if
  309. @buff_checker[i] != battler.buff_icons[i]}
  310. end
  311.  
  312. def display_status?
  313. return true if !battler.state_icons.empty?
  314. return true if !battler.buff_icons.empty?
  315. return false
  316. end
  317.  
  318. def create_states_icons
  319. return if disposed?
  320. return if !@states.nil?
  321. @states = ::Sprite.new(@view)
  322. @states.bitmap = Bitmap.new(144, 24)
  323. @n_back.nil? ? y_plus = BHP_BarDimentions[3] : y_plus = @n_back.height
  324. pos = [BeScreenPos_X, BeScreenPos_Y, y_plus] if boss?
  325. pos = [NeScreenPos_X, NeScreenPos_Y, y_plus] if !boss?
  326. @states.x = pos[0] + 10
  327. @states.y = pos[1] + pos[2] + 24
  328. @states.zoom_x = 0.8
  329. @states.zoom_y = 0.8
  330. refresh_states_icons
  331. end
  332.  
  333. def dispose_state_icons
  334. return if @states.nil?
  335. @states.bitmap.dispose
  336. @states.dispose
  337. @states = nil
  338. end
  339.  
  340. def refresh_states_icons
  341. 4.times.each {|i| @state_checker[i] = battler.state_icons[i]}
  342. 2.times.each {|i| @buff_checker[i] = battler.buff_icons[i]}
  343. return if @states.nil?
  344. @states.bitmap.clear
  345. x = 0
  346. battler.state_icons.each {|icon| draw_icon(icon, x, 0) ; x += 24
  347. break if x == 96}
  348. count = 0
  349. battler.buff_icons.each {|icon| draw_icon(icon, x, 0) ; x += 24 ; count += 1
  350. break if count == 2}
  351. end
  352.  
  353. def draw_icon(icon_index, x, y, enabled = true)
  354. bit = Cache.system("Iconset")
  355. rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  356. @states.bitmap.blt(x, y, bit, rect, enabled ? 255 : 150)
  357. end
  358.  
  359. def dispose
  360. self.bitmap.dispose
  361. dispose_state_icons
  362. super
  363. end
  364. end
  365.  
  366. # Make the enemy bars to load when enemy is hited
  367. class Projectile < Game_Character
  368. alias falcao_lifebars_execute execute_damageto_enemy
  369. def execute_damageto_enemy(event)
  370. $game_system.enemy_lifeobject = event if @user.is_a?(Game_Player) &&
  371. !event.battler.object
  372. falcao_lifebars_execute(event)
  373. end
  374. end