Advertisement
Guest User

Untitled

a guest
Mar 17th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.04 KB | None | 0 0
  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.  
  19. # * Usage and Installation
  20. # Just copy and paste below the Pearl ABS System
  21. #
  22. # * Commands
  23. # PearlBars.hide - Hide the actor bars
  24. # PearlBars.show - Show the actor bars (by default)
  25. #
  26. # PearlBars.enemy_auto(id)- Show automatically the enemy HP bars without need
  27. # to hit, this is mostly used for bosses, change id for the event id
  28. # Tag any enemy with Enemy Boss Bar = true to eneble the boss bar mode
  29. #------------------------------------------------------------------------------
  30. module PearlBars
  31. #=============================================================================
  32. # * Actors bars configuration
  33. #
  34. # Bars x and y position on the screen
  35. ScreenPos_X = 182
  36. ScreenPos_Y = 380
  37. #
  38. # Dimentions of the bars you cant exceed 300 width x 100 height
  39. # x y width height
  40. HP_BarDimentions = [-2, 6, 118, 14]
  41. MP_BarDimentions = [100, 6, 118, 14]
  42. EX_BarDimentions = [202, 6, 118, 10]
  43.  
  44. # Tp info x y
  45. TP_Info = [-100, 64]
  46. #
  47. # color definition
  48. # color 1 R G B Opa color 2 R G B Opa
  49. HP_Color = [Color.new(205, 255, 205, 200), Color.new(10, 220, 45, 200)]
  50. MP_Color = [Color.new(180, 225, 245, 200), Color.new(20, 160, 225, 200)]
  51. EX_Color = [Color.new(180, 225, 245, 200), Color.new(20, 160, 225, 200)]
  52.  
  53. # Do you want to display graphics instead of script drawing bars?
  54. # if so, fill this actors bars graphics requirements
  55.  
  56. ActorsHp = "Actors_HP" # Actor Hp graphic bar name (inside quotation marks)
  57. ActorsMp = "Actors_MP" # Actor Mp graphic bar name
  58. ActorsExp = "Actors_Exp" # Actor Experience, if you dont want it leave it ""
  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 = 390
  66. NeScreenPos_Y = 10
  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 = "" # normal enemy hp bar
  78. NormalBack = "" # 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 = "" # Boss enemy Hp bar
  96. BossBack = "" # 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. class Spriteset_Map
  110.  
  111. alias falcaopearl_lifebars_create create_pictures
  112. def create_pictures
  113. create_hud_lifebars
  114. falcaopearl_lifebars_create
  115. end
  116.  
  117. def create_hud_lifebars
  118. @enemy_lifeobject = $game_system.enemy_lifeobject
  119. @enemyhpsp = Sprite_LifeBars.new(@viewport2, @enemy_lifeobject) if
  120. not @enemy_lifeobject.nil?
  121. end
  122.  
  123. def create_actorlifebars
  124. return if !@actor_lifebar.nil?
  125. @actor_lifebar = Sprite_LifeBars.new(@viewport2, $game_player)
  126. end
  127.  
  128. def dispose_actorlifebars
  129. return if @actor_lifebar.nil?
  130. @actor_lifebar.dispose
  131. @actor_lifebar = nil
  132. end
  133.  
  134. alias falcaopearl_lifebars_update update
  135. def update
  136. update_lifebars_sprites
  137. falcaopearl_lifebars_update
  138. end
  139.  
  140. def update_lifebars_sprites
  141. $game_system.pearlbars.nil? ? create_actorlifebars : dispose_actorlifebars
  142. @actor_lifebar.update unless @actor_lifebar.nil?
  143.  
  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. if @old_tp != battler.tp
  282. @old_tp = battler.tp
  283. @character.actor.apply_usability if @character.is_a?(Game_Player)
  284. refresh_contents
  285. end
  286.  
  287. elsif battler.is_a?(Game_Enemy)
  288. if boss?
  289. dispose if battler.dead?
  290. else
  291. if @erasetimer > 0
  292. @erasetimer -= 1
  293. self.opacity -= 10 if @erasetimer <= 25
  294. @states.opacity = self.opacity if !@states.nil?
  295. dispose if @erasetimer == 0
  296. end
  297. end
  298. update_enemy_status_icons
  299. end
  300. end
  301.  
  302. # enemy status icons engine
  303. def update_enemy_status_icons
  304. display_status? ? create_states_icons : dispose_state_icons
  305. 4.times.each {|i| refresh_states_icons if
  306. @state_checker[i] != battler.state_icons[i]}
  307. 2.times.each {|i| refresh_states_icons if
  308. @buff_checker[i] != battler.buff_icons[i]}
  309. end
  310.  
  311. def display_status?
  312. return true if !battler.state_icons.empty?
  313. return true if !battler.buff_icons.empty?
  314. return false
  315. end
  316.  
  317. def create_states_icons
  318. return if disposed?
  319. return if !@states.nil?
  320. @states = ::Sprite.new(@view)
  321. @states.bitmap = Bitmap.new(144, 24)
  322. @n_back.nil? ? y_plus = BHP_BarDimentions[3] : y_plus = @n_back.height
  323. pos = [BeScreenPos_X, BeScreenPos_Y, y_plus] if boss?
  324. pos = [NeScreenPos_X, NeScreenPos_Y, y_plus] if !boss?
  325. @states.x = pos[0] + 10
  326. @states.y = pos[1] + pos[2] + 24
  327. @states.zoom_x = 0.8
  328. @states.zoom_y = 0.8
  329. refresh_states_icons
  330. end
  331.  
  332. def dispose_state_icons
  333. return if @states.nil?
  334. @states.bitmap.dispose
  335. @states.dispose
  336. @states = nil
  337. end
  338.  
  339. def refresh_states_icons
  340. 4.times.each {|i| @state_checker[i] = battler.state_icons[i]}
  341. 2.times.each {|i| @buff_checker[i] = battler.buff_icons[i]}
  342. return if @states.nil?
  343. @states.bitmap.clear
  344. x = 0
  345. battler.state_icons.each {|icon| draw_icon(icon, x, 0) ; x += 24
  346. break if x == 96}
  347. count = 0
  348. battler.buff_icons.each {|icon| draw_icon(icon, x, 0) ; x += 24 ; count += 1
  349. break if count == 2}
  350. end
  351.  
  352. def draw_icon(icon_index, x, y, enabled = true)
  353. bit = Cache.system("Iconset")
  354. rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  355. @states.bitmap.blt(x, y, bit, rect, enabled ? 255 : 150)
  356. end
  357.  
  358. def dispose
  359. self.bitmap.dispose
  360. dispose_state_icons
  361. super
  362. end
  363. end
  364.  
  365. # Make the enemy bars to load when enemy is hited
  366. class Projectile < Game_Character
  367. alias falcao_lifebars_execute execute_damageto_enemy
  368. def execute_damageto_enemy(event)
  369. $game_system.enemy_lifeobject = event if @user.is_a?(Game_Player) &&
  370. !event.battler.object
  371. falcao_lifebars_execute(event)
  372. end
  373. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement