Guest User

Untitled

a guest
Jun 28th, 2017
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.17 KB | None | 0 0
  1. #==============================================================================
  2. # Vampyr HUD
  3. #==============================================================================
  4. # Switch ID that show or hide the HUD
  5. OnOff_Switch = 2
  6.  
  7. # Show HP, MP and EXP Bars?
  8. Show_Status = true
  9.  
  10. # Text displayed on skills window
  11. Show_Skills = true
  12. Skills_Text = "Skills"
  13.  
  14. # Text displayed on items window
  15. Show_Items = true
  16. Items_Text = "Items"
  17.  
  18. # Text displayed on ammunitions window
  19. Show_Ammos = true
  20. Ammo_Text = "Munition"
  21.  
  22. # The name of the font
  23. Font_Name = Font.default_name
  24.  
  25. # The size of the font
  26. Font_Size = 16
  27.  
  28. Level_Font_Size = 18
  29.  
  30. #------------------------------------------------------------------------------
  31. if Vampyr_Kernel.enabled?("Vampyr SBABS")
  32. #------------------------------------------------------------------------------
  33. Vampyr_Kernel.register("Vampyr HUD", 1.1, "12/06/2009")
  34. #------------------------------------------------------------------------------
  35. class Vampyr_HUD1 < Sprite
  36.  
  37. def initialize(viewport)
  38. super(viewport)
  39. self.x, self.y = 1, 1
  40. @base = Cache.system("Actor Base")
  41. @hpbar = Cache.system("Actor HP Bar")
  42. @mpbar = Cache.system("Actor MP Bar")
  43. @expbar = Cache.system("Actor Exp Bar")
  44. self.bitmap = Bitmap.new(156, 100)
  45. self.bitmap.font.name = Font_Name
  46. self.bitmap.font.size = Font_Size
  47. refresh
  48. end
  49.  
  50. def update
  51. super
  52. self.visible = (OnOff_Switch <= 0 or $game_switches[OnOff_Switch])
  53. update_opacity
  54. refresh if something_changed?
  55. end
  56.  
  57. def refresh
  58. @actor = $game_party.members[0]
  59. return if @actor == nil
  60. @old_hp = @actor.hp
  61. @old_mp = @actor.mp
  62. @old_exp = @actor.exp
  63. self.bitmap.clear
  64. draw_hpbar(@actor, 0, 0)
  65. draw_mpbar(@actor, 0, 20)
  66. draw_expbar(@actor, 0, 40) if @actor.next_exp > 0
  67. end
  68.  
  69. def draw_hpbar(actor, x, y)
  70. self.bitmap.draw_outlined_text(x, y, 24, Font_Size, Vocab::hp_a)
  71. rect = Rect.new(0, 0, @hpbar.width*actor.hp/actor.maxhp, @hpbar.height)
  72. self.bitmap.blt(x+24, y, @base, @base.rect)
  73. self.bitmap.blt(x+24, y, @hpbar, rect)
  74. self.bitmap.draw_text(x+24,y,@hpbar.width/2-10,Font_Size,"#{actor.hp}",2)
  75. self.bitmap.draw_text([email protected]/2-10,y,20,Font_Size,"/",1)
  76. self.bitmap.draw_text([email protected]/2+10,y,@hpbar.width/2-10,Font_Size,"#{actor.maxhp}",0)
  77. end
  78.  
  79. def draw_mpbar(actor, x, y)
  80. self.bitmap.draw_outlined_text(x, y, 24, Font_Size, Vocab::mp_a)
  81. rect = Rect.new(0, 0, @mpbar.width*actor.mp/actor.maxmp, @mpbar.height)
  82. self.bitmap.blt(x+24, y, @base, @base.rect)
  83. self.bitmap.blt(x+24, y, @mpbar, rect)
  84. self.bitmap.draw_text(x+24,y,@hpbar.width/2-10,Font_Size,"#{actor.mp}",2)
  85. self.bitmap.draw_text([email protected]/2-10,y,20,Font_Size,"/",1)
  86. self.bitmap.draw_text([email protected]/2+10,y,@hpbar.width/2-10,Font_Size,"#{actor.maxmp}",0)
  87. end
  88.  
  89. def draw_expbar(actor, x, y)
  90. self.bitmap.draw_outlined_text(x, y, 24, Font_Size, "Exp")
  91. rect = Rect.new(0, 0, @expbar.width*actor.current_exp/actor.next_exp, @expbar.height)
  92. self.bitmap.blt(x+24, y, @base, @base.rect)
  93. self.bitmap.blt(x+24, y, @expbar, rect)
  94. exp = actor.next_exp > 0 ? 100*actor.current_exp/actor.next_exp : 100
  95. self.bitmap.draw_text(x+24,y, @expbar.width, Font_Size, "#{exp.to_i} %",1)
  96. self.bitmap.font.size = Level_Font_Size
  97. self.bitmap.draw_outlined_text(x,y+Level_Font_Size+2,@expbar.width - 48,Level_Font_Size,"Level #{actor.level}",0)
  98. self.bitmap.font.size = Font_Size
  99. end
  100.  
  101. def something_changed?
  102. return true if $game_party.members.size > 0 && @actor == nil
  103. return false if $game_party.members.size <= 0
  104. return true if @old_hp != @actor.hp
  105. return true if @old_mp != @actor.mp
  106. return true if @old_exp != @actor.exp
  107. return true if @actor != $game_party.members[0]
  108. return false
  109. end
  110.  
  111. def update_opacity
  112. if $game_player.screen_x <= (self.bitmap.width+16) and $game_player.screen_y <= (self.bitmap.height+16)
  113. self.opacity -= 10
  114. elsif self.opacity < 255
  115. self.opacity += 10
  116. end
  117. end
  118.  
  119. def dispose
  120. self.bitmap.dispose
  121. super
  122. end
  123.  
  124. end
  125.  
  126. #------------------------------------------------------------------------------
  127. class Vampyr_HUD2 < Sprite
  128.  
  129. def initialize(viewport)
  130. super(viewport)
  131. @bg = Cache.system("Ammos Base")
  132. self.y = [email protected](Font_Size/2)-1
  133. self.bitmap = Bitmap.new(@bg.width, @bg.height+(Font_Size/2))
  134. self.bitmap.font.name = Font_Name
  135. self.bitmap.font.size = Font_Size
  136. refresh
  137. end
  138.  
  139. def update
  140. super
  141. self.visible = (OnOff_Switch <= 0 or $game_switches[OnOff_Switch])
  142. update_opacity
  143. refresh if something_changed?
  144. end
  145.  
  146. def refresh
  147. @actor = $game_party.members[0]
  148. return if @actor == nil
  149. @weapon1 = @actor.weapons[0]
  150. @weapon2 = @actor.weapons[1]
  151. @count1 = $game_party.item_number(@actor.ammos[@weapon1.id])
  152. @count2 = $game_party.item_number(@actor.ammos[@weapon2.id])
  153. self.bitmap.clear
  154. self.bitmap.blt(0, 10, @bg, @bg.rect)
  155. draw_ammos
  156. end
  157.  
  158. def draw_ammos
  159. if @actor.weapons[0] != nil and @actor.ammos[@actor.weapons[0].id] != nil
  160. draw_icon(@actor.ammos[@actor.weapons[0].id].icon_index, 4, 14)
  161. self.bitmap.draw_outlined_text(0, self.bitmap.height-Font_Size, 32, Font_Size, @count1.to_s, 1)
  162. end
  163. if @actor.weapons[1] != nil and @actor.ammos[@actor.weapons[1].id] != nil
  164. draw_icon(@actor.ammos[@actor.weapons[1].id].icon_index, 36, 14)
  165. end
  166. self.bitmap.draw_outlined_text(0, 0, self.bitmap.width, Font_Size, Ammo_Text, 1)
  167. end
  168.  
  169. def something_changed?
  170. return true if $game_party.members.size > 0 && @actor == nil
  171. return false if $game_party.members.size <= 0
  172. return true if @weapon1 != @actor.weapons[0]
  173. return true if @weapon2 != @actor.weapons[1]
  174. return true if @actor != $game_party.members[0]
  175. return true if @count1 != $game_party.item_number(@actor.ammos[@weapon1.id])
  176. return true if @count2 != $game_party.item_number(@actor.ammos[@weapon2.id])
  177. return false
  178. end
  179.  
  180. def update_opacity
  181. if $game_player.screen_x <= (self.bitmap.width+16) and $game_player.screen_y >= (Graphics.height-self.bitmap.height-16)
  182. self.opacity -= 10
  183. elsif self.opacity < 255
  184. self.opacity += 10
  185. end
  186. end
  187.  
  188. def dispose
  189. self.bitmap.dispose
  190. super
  191. end
  192.  
  193. end
  194.  
  195. #------------------------------------------------------------------------------
  196. class Vampyr_HUD3 < Sprite
  197.  
  198. def initialize(viewport)
  199. super(viewport)
  200. @bg = Cache.system("Skills Base")
  201. self.y = [email protected](Font_Size/2)-1
  202. self.bitmap = Bitmap.new(@bg.width, @bg.height+(Font_Size/2))
  203. self.bitmap.font.name = Font_Name
  204. self.bitmap.font.size = Font_Size
  205. refresh
  206. end
  207.  
  208. def update
  209. super
  210. self.visible = (OnOff_Switch <= 0 or $game_switches[OnOff_Switch])
  211. update_opacity
  212. refresh if something_changed?
  213. end
  214.  
  215. def refresh
  216. @actor = $game_party.members[0]
  217. return if @actor == nil
  218. @hotkeys = {}
  219. @actor.skill_hotkeys.each { |k, v| @hotkeys[k] = v }
  220. self.bitmap.clear
  221. self.bitmap.blt(0, 10, @bg, @bg.rect)
  222. draw_skills
  223. end
  224.  
  225. def draw_skills
  226. count = 0
  227. @actor.skill_hotkeys.sort.each { |key, value|
  228. next if value.nil?
  229. skill = $data_skills[value]
  230. next if skill.nil?
  231. draw_icon(skill.icon_index, 32*count+4, 14)
  232. self.bitmap.draw_outlined_text(32*count, self.bitmap.height-Font_Size, 32, Font_Size, Keys.name(key), 1)
  233. count += 1
  234. }
  235. self.bitmap.draw_outlined_text(0, 0, self.bitmap.width, Font_Size, Skills_Text, 1)
  236. end
  237.  
  238. def something_changed?
  239. return true if $game_party.members.size > 0 && @actor == nil
  240. return false if $game_party.members.size <= 0
  241. return true if @actor != $game_party.members[0]
  242. return true if @hotkeys != @actor.skill_hotkeys
  243. return false
  244. end
  245.  
  246. def update_opacity
  247. if $game_player.screen_x >= (Graphics.width-self.bitmap.width-16) and $game_player.screen_y >= (Graphics.height-self.bitmap.height-16)
  248. self.opacity -= 10
  249. elsif self.opacity < 255
  250. self.opacity += 10
  251. end
  252. end
  253.  
  254. def dispose
  255. self.bitmap.dispose
  256. super
  257. end
  258.  
  259. end
  260.  
  261. #------------------------------------------------------------------------------
  262. class Vampyr_HUD4 < Sprite
  263.  
  264. def initialize(viewport)
  265. super(viewport)
  266. @bg = Cache.system("Items Base")
  267. self.x, self.y = [email protected], 1
  268. self.bitmap = Bitmap.new(@bg.width, @bg.height+(Font_Size/2))
  269. self.bitmap.font.name = Font_Name
  270. self.bitmap.font.size = Font_Size
  271. refresh
  272. end
  273.  
  274. def update
  275. super
  276. self.visible = (OnOff_Switch <= 0 or $game_switches[OnOff_Switch])
  277. update_opacity
  278. refresh if something_changed?
  279. end
  280.  
  281. def refresh
  282. @actor = $game_party.members[0]
  283. return if @actor == nil
  284. @hotkeys = {}
  285. @actor.item_hotkeys.each { |k, v| @hotkeys[k] = v }
  286. self.bitmap.clear
  287. self.bitmap.blt(0, 10, @bg, @bg.rect)
  288. draw_items
  289. end
  290.  
  291. def draw_items
  292. count = 0
  293. @actor.item_hotkeys.sort.each { |key, value|
  294. next if value.nil?
  295. item = $data_items[value]
  296. next if item.nil?
  297. draw_icon(item.icon_index, 32*count+4, 14)
  298. self.bitmap.draw_outlined_text(32*count, self.bitmap.height-Font_Size, 32, Font_Size, Keys.name(key), 1)
  299. count += 1
  300. }
  301. self.bitmap.draw_outlined_text(0, 0, self.bitmap.width, Font_Size, Items_Text, 1)
  302. end
  303.  
  304. def something_changed?
  305. return true if $game_party.members.size > 0 && @actor == nil
  306. return false if $game_party.members.size <= 0
  307. return true if @actor != $game_party.members[0]
  308. return true if @hotkeys.to_s != @actor.item_hotkeys.to_s
  309. return false
  310. end
  311.  
  312. def update_opacity
  313. if $game_player.screen_x >= (Graphics.width-self.bitmap.width-16) and $game_player.screen_y <= (self.bitmap.height+16)
  314. self.opacity -= 10
  315. elsif self.opacity < 255
  316. self.opacity += 10
  317. end
  318. end
  319.  
  320. def dispose
  321. self.bitmap.dispose
  322. super
  323. end
  324.  
  325. end
  326.  
  327. #------------------------------------------------------------------------------
  328. class Spriteset_Map
  329.  
  330. alias vampyr_hud_initialize initialize
  331. alias vampyr_hud_update update
  332. alias vampyr_hud_dispose dispose
  333.  
  334. def initialize
  335. $vampyr_hud1 = Vampyr_HUD1.new(@viewport3) if Show_Status
  336. $vampyr_hud2 = Vampyr_HUD2.new(@viewport3) if Show_Ammos
  337. $vampyr_hud3 = Vampyr_HUD3.new(@viewport3) if Show_Skills
  338. $vampyr_hud4 = Vampyr_HUD4.new(@viewport3) if Show_Items
  339. vampyr_hud_initialize
  340. end
  341.  
  342. def update
  343. vampyr_hud_update
  344. $vampyr_hud1.update if Show_Status
  345. $vampyr_hud2.update if Show_Ammos
  346. $vampyr_hud3.update if Show_Skills
  347. $vampyr_hud4.update if Show_Items
  348. end
  349.  
  350. def dispose
  351. vampyr_hud_dispose
  352. $vampyr_hud1.dispose if Show_Status
  353. $vampyr_hud2.dispose if Show_Ammos
  354. $vampyr_hud3.dispose if Show_Skills
  355. $vampyr_hud4.dispose if Show_Items
  356. end
  357.  
  358. end
  359.  
  360. #------------------------------------------------------------------------------
  361. end
Advertisement
Add Comment
Please, Sign In to add comment