Guest User

Script5 Falcao

a guest
Jan 22nd, 2016
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.06 KB | None | 0 0
  1. #===============================================================================
  2. # * Falcao Pearl ABS script shelf # 4
  3. #
  4. # This script handles the Skillbar funtions
  5. # it is designed to support the 'Mouse System Buttons script 1.6 and above too
  6. # you can trigger tools by clicking the icons on the toolbar!
  7. #===============================================================================
  8.  
  9. module PearlSkillBar
  10.  
  11. # Skillbar X position in tiles
  12. Tile_X = 4
  13.  
  14. # Skillbar Y position in tiles
  15. Tile_Y = 11
  16.  
  17. # Layout graphic
  18. LayOutImage = "Pearl Skillbar"
  19.  
  20. # Follower attack command icon index
  21. ToggleIcon = 116
  22.  
  23. # * Commands
  24. #
  25. # PearlSkillBar.hide - hide the skillbar
  26. # PearlSkillBar.show - show the skillbar
  27. #-----------------------------------------------------------------------------
  28.  
  29. def self.hide
  30. $game_system.skillbar_enable = true
  31. end
  32.  
  33. def self.show
  34. $game_system.skillbar_enable = nil
  35. end
  36.  
  37. def self.hidden?
  38. !$game_system.skillbar_enable.nil?
  39. end
  40. end
  41.  
  42. class Game_System
  43. attr_accessor :skillbar_enable, :pearlbars, :enemy_lifeobject
  44. alias falcaopearl_abs_hud initialize
  45. def initialize
  46. unless PearlKernel::StartWithHud
  47. @skillbar_enable = true
  48. @pearlbars = true
  49. end
  50. falcaopearl_abs_hud
  51. end
  52. end
  53.  
  54. class Sprite_PearlTool < Sprite
  55. include PearlSkillBar
  56. attr_accessor :actor
  57. def initialize(view, custom_pos=nil)
  58. super(view)
  59. @layout = ::Sprite.new(view)
  60. @layout.bitmap = Cache.picture(LayOutImage)
  61. @icons = ::Sprite.new(view)
  62. @icons.bitmap = Bitmap.new(@layout.bitmap.width, @layout.bitmap.height)
  63. self.bitmap = Bitmap.new(@layout.bitmap.width+32, @layout.bitmap.height+32)
  64. if custom_pos.nil?
  65. @layout.x = Tile_X * 32
  66. @layout.y = Tile_Y * 32
  67. else
  68. @layout.x = custom_pos[0]
  69. @layout.y = custom_pos[1]
  70. end
  71. @icons.x = @layout.x
  72. @icons.y = @layout.y
  73. self.x = @layout.x - 16
  74. self.y = @layout.y - 12
  75. self.z = self.z + 1
  76. @actor = $game_player.actor
  77. @actor.apply_usability
  78. @old_usability = []
  79. 8.times.each {|i| @old_usability[i] = @actor.usability[i]}
  80. @framer = 0
  81. @info_keys = ::Sprite.new(view)
  82. @info_keys.bitmap = Bitmap.new(self.bitmap.width, self.bitmap.height)
  83. @info_keys.x = self.x; @info_keys.y = self.y; @info_keys.z = self.z
  84. draw_key_info
  85. refresh_icons
  86. refresh_texts
  87. @view = view
  88. @on_map = SceneManager.scene_is?(Scene_Map)
  89. @mouse_exist = defined?(Map_Buttons).is_a?(String)
  90. @mouse_exist = false if @mouse_exist && !SceneManager.scene_is?(Scene_Map)
  91. update
  92. end
  93.  
  94. def draw_key_info
  95. @info_keys.bitmap.font.size = 15
  96. letters = [Key::Weapon[1], Key::Armor[1], Key::Item[1], Key::Item2[1],
  97. Key::Skill[1],Key::Skill2[1],Key::Skill3[1],Key::Skill4[1],Key::Follower[1]]
  98. x = 28
  99. for i in letters
  100. @info_keys.bitmap.draw_text(x, -2, @info_keys.bitmap.width, 32, i)
  101. x += 32
  102. end
  103. end
  104.  
  105. def refresh_texts
  106. self.bitmap.clear
  107. self.bitmap.font.size = 15
  108. refresh_cooldown
  109. refresh_ammo
  110. end
  111.  
  112. def number(operand)
  113. return (operand / 60).to_i + 1
  114. end
  115.  
  116. def flagged(item, type)
  117. return :false if !item.cool_enabled? and type == 1
  118. return item.itemcost if type == 2
  119. end
  120.  
  121. # Refresh toolbar icons
  122. def refresh_icons
  123. @icons.bitmap.clear
  124. icon = [@actor.equips[0], @actor.equips[1], @actor.assigned_item,
  125. @actor.assigned_item2, @actor.assigned_skill, @actor.assigned_skill2,
  126. @actor.assigned_skill3, @actor.assigned_skill4, ToggleIcon]
  127. x = 4
  128. icon.each {|i|
  129. if !i.nil? and !i.is_a?(Fixnum)
  130. if i.is_a?(RPG::Item) || i.is_a?(RPG::Skill)
  131. draw_icon(i.icon_index, x, 6, @actor.usable?(i))
  132. else
  133. if i.is_a?(RPG::Weapon)
  134. enable = @actor.usability[0] ; enable = true if enable.nil?
  135. draw_icon(i.icon_index, x, 6, enable)
  136. elsif i.is_a?(RPG::Armor)
  137. enable = @actor.usability[1] ; enable = true if enable.nil?
  138. draw_icon(i.icon_index, x, 6, enable)
  139. end
  140. end
  141. end
  142. draw_icon(i, x, 6) if i.is_a?(Fixnum) ; x += 32}
  143. @now_equip = [@actor.equips[0], @actor.equips[1], @actor.assigned_item,
  144. @actor.assigned_item2, @actor.assigned_skill, @actor.assigned_skill2,
  145. @actor.assigned_skill3, @actor.assigned_skill4]
  146. end
  147.  
  148. def update
  149. update_mouse_tiles if @mouse_exist
  150. update_cooldown
  151. update_ammo_tools
  152. update_usability_enable
  153. refresh_icons if @now_equip[0] != @actor.equips[0]
  154. refresh_icons if @now_equip[1] != @actor.equips[1]
  155. refresh_icons if @now_equip[2] != @actor.assigned_item
  156. refresh_icons if @now_equip[3] != @actor.assigned_item2
  157. refresh_icons if @now_equip[4] != @actor.assigned_skill
  158. refresh_icons if @now_equip[5] != @actor.assigned_skill2
  159. refresh_icons if @now_equip[6] != @actor.assigned_skill3
  160. refresh_icons if @now_equip[7] != @actor.assigned_skill4
  161. update_fade_effect
  162. end
  163.  
  164. # fade effect when player is behind the toolbar
  165. def update_fade_effect
  166. if behind_toolbar?
  167. if self.opacity >= 60
  168. self.opacity -= 10
  169. @layout.opacity = @icons.opacity = @info_keys.opacity = self.opacity
  170. end
  171. elsif self.opacity != 255
  172. self.opacity += 10
  173. @layout.opacity = @icons.opacity = @info_keys.opacity = self.opacity
  174. end
  175. end
  176.  
  177. def behind_toolbar?
  178. return false unless @on_map
  179. px = ($game_player.screen_x / 32).to_i
  180. py = ($game_player.screen_y / 32).to_i
  181. 9.times.each {|x| return true if px == Tile_X + x and py == Tile_Y}
  182. return false
  183. end
  184.  
  185. # refresh the icons when the usability change
  186. def update_usability_enable
  187. 8.times.each {|i| refresh_icons if @old_usability[i] != @actor.usability[i]}
  188. end
  189.  
  190. #-----------------------------------------------
  191. # ammunition engine
  192. def ammo_ready?(item)
  193. return false if item.nil?
  194. return true if item.has_data.nil? && item.is_a?(RPG::Item) &&
  195. item.consumable
  196. return false if flagged(item, 2).nil?
  197. return true if flagged(item, 2) != 0
  198. return false
  199. end
  200.  
  201. # get item cost
  202. def itemcost(item)
  203. return $game_party.item_number(item) if item.has_data.nil? &&
  204. item.is_a?(RPG::Item) && item.consumable
  205. if !flagged(item, 2).nil? and flagged(item, 2) != 0
  206. return $game_party.item_number($data_items[flagged(item, 2)])
  207. end
  208. return 0
  209. end
  210.  
  211. # Ammo refresher
  212. def refresh_ammo
  213. if ammo_ready?(@actor.equips[0])
  214. @wnumber = itemcost(@actor.equips[0])
  215. self.bitmap.draw_text(18, 24, 32,32, @wnumber.to_s, 1)
  216. end
  217. if ammo_ready?(@actor.equips[1])
  218. @anumber = itemcost(@actor.equips[1])
  219. self.bitmap.draw_text(50, 24, 32,32, @anumber.to_s, 1)
  220. end
  221. if ammo_ready?(@actor.assigned_item)
  222. @inumber = itemcost(@actor.assigned_item)
  223. self.bitmap.draw_text(82, 24, 32,32, @inumber.to_s, 1)
  224. end
  225. if ammo_ready?(@actor.assigned_item2)
  226. @inumber2 = itemcost(@actor.assigned_item2)
  227. self.bitmap.draw_text(112, 24, 32,32, @inumber2.to_s, 1) # item 2
  228. end
  229. if ammo_ready?(@actor.assigned_skill)
  230. @snumber = itemcost(@actor.assigned_skill)
  231. self.bitmap.draw_text(144, 24, 32,32, @snumber.to_s, 1)
  232. end
  233. if ammo_ready?(@actor.assigned_skill2)
  234. @snumber2 = itemcost(@actor.assigned_skill2)
  235. self.bitmap.draw_text(176, 24, 32,32, @snumber2.to_s, 1) # skill 2
  236. end
  237. if ammo_ready?(@actor.assigned_skill3)
  238. @snumber3 = itemcost(@actor.assigned_skill3)
  239. self.bitmap.draw_text(208, 24, 32,32, @snumber3.to_s, 1) # skill 3
  240. end
  241. if ammo_ready?(@actor.assigned_skill4)
  242. @snumber4 = itemcost(@actor.assigned_skill4)
  243. self.bitmap.draw_text(240, 24, 32,32, @snumber4.to_s, 1) # skill 4
  244. end
  245.  
  246. end
  247.  
  248. def update_ammo_tools
  249. refresh_texts if ammo_ready?(@actor.equips[0]) &&
  250. @wnumber != itemcost(@actor.equips[0])
  251. refresh_texts if ammo_ready?(@actor.equips[1]) &&
  252. @anumber != itemcost(@actor.equips[1])
  253.  
  254. if ammo_ready?(@actor.assigned_item) &&
  255. @inumber != itemcost(@actor.assigned_item)
  256. refresh_texts
  257. end
  258. refresh_texts if ammo_ready?(@actor.assigned_item2) && #@inumber2
  259. @inumber2 != itemcost(@actor.assigned_item2)
  260. refresh_texts if ammo_ready?(@actor.assigned_skill) &&
  261. @snumber != itemcost(@actor.assigned_skill)
  262. refresh_texts if ammo_ready?(@actor.assigned_skill2) && #@snumber2
  263. @snumber2 != itemcost(@actor.assigned_skill2)
  264. # new anmmo
  265. refresh_texts if ammo_ready?(@actor.assigned_skill3) && #@snumber3
  266. @snumber3 != itemcost(@actor.assigned_skill3)
  267. refresh_texts if ammo_ready?(@actor.assigned_skill4) && #@snumber4
  268. @snumber4 != itemcost(@actor.assigned_skill4)
  269. end
  270.  
  271. #--------------------------------------
  272. # cooldown engine
  273. def cool_down_active?
  274. return true if skill_cooldown > 0 || weapon_cooldown > 0 ||
  275. armor_cooldown > 0 || item_cooldown > 0 || skill_cooldown2 > 0 ||
  276. item_cooldown2 > 0 || skill_cooldown3 > 0 || skill_cooldown4 > 0
  277. return false
  278. end
  279.  
  280. def weapon_cooldown
  281. if [email protected][0].nil?
  282. return 0 if flagged(@actor.equips[0], 1) == :false
  283. cd = @actor.weapon_cooldown[@actor.equips[0].id]
  284. return cd unless cd.nil?
  285. end
  286. return 0
  287. end
  288.  
  289. def armor_cooldown
  290. if [email protected][1].nil?
  291. return 0 if flagged(@actor.equips[1], 1) == :false
  292. cd = @actor.armor_cooldown[@actor.equips[1].id]
  293. return cd unless cd.nil?
  294. end
  295. return 0
  296. end
  297.  
  298. def item_cooldown
  299. if [email protected]_item.nil?
  300. return 0 if flagged(@actor.assigned_item, 1) == :false
  301. cd = @actor.item_cooldown[@actor.assigned_item.id]
  302. return cd unless cd.nil?
  303. end
  304. return 0
  305. end
  306.  
  307. def item_cooldown2
  308. if [email protected]_item2.nil?
  309. return 0 if flagged(@actor.assigned_item2, 1) == :false
  310. cd = @actor.item_cooldown[@actor.assigned_item2.id]
  311. return cd unless cd.nil?
  312. end
  313. return 0
  314. end
  315.  
  316. def skill_cooldown
  317. if [email protected]_skill.nil?
  318. return 0 if flagged(@actor.assigned_skill, 1) == :false
  319. cd = @actor.skill_cooldown[@actor.assigned_skill.id]
  320. return cd unless cd.nil?
  321. end
  322. return 0
  323. end
  324.  
  325. def skill_cooldown2
  326. if [email protected]_skill2.nil?
  327. return 0 if flagged(@actor.assigned_skill2, 1) == :false
  328. cd = @actor.skill_cooldown[@actor.assigned_skill2.id]
  329. return cd unless cd.nil?
  330. end
  331. return 0
  332. end
  333.  
  334. # two new skillls
  335. def skill_cooldown3
  336. if [email protected]_skill3.nil?
  337. return 0 if flagged(@actor.assigned_skill3, 1) == :false
  338. cd = @actor.skill_cooldown[@actor.assigned_skill3.id]
  339. return cd unless cd.nil?
  340. end
  341. return 0
  342. end
  343.  
  344. def skill_cooldown4 # 4
  345. if [email protected]_skill4.nil?
  346. return 0 if flagged(@actor.assigned_skill4, 1) == :false
  347. cd = @actor.skill_cooldown[@actor.assigned_skill4.id]
  348. return cd unless cd.nil?
  349. end
  350. return 0
  351. end
  352.  
  353.  
  354. # Cooldown refresher
  355. def refresh_cooldown
  356. wcd = number(weapon_cooldown)
  357. self.bitmap.draw_text(18, 36,32,32, wcd.to_s, 1) if weapon_cooldown > 10
  358. acd = number(armor_cooldown)
  359. self.bitmap.draw_text(50, 36,32,32, acd.to_s, 1) if armor_cooldown > 10
  360. icd = number(item_cooldown)
  361. self.bitmap.draw_text(82, 36,32,32, icd.to_s, 1) if item_cooldown > 10
  362. icd2 = number(item_cooldown2)
  363. self.bitmap.draw_text(112, 36,32,32, icd2.to_s, 1) if item_cooldown2 > 10
  364. scd = number(skill_cooldown)
  365. self.bitmap.draw_text(144, 36,32,32, scd.to_s, 1) if skill_cooldown > 10
  366. scd2 = number(skill_cooldown2)
  367. self.bitmap.draw_text(176, 36,32,32, scd2.to_s, 1) if skill_cooldown2 > 10
  368. scd3 = number(skill_cooldown3)
  369. self.bitmap.draw_text(208, 36,32,32, scd3.to_s, 1) if skill_cooldown3 > 10
  370. scd4 = number(skill_cooldown4)
  371. self.bitmap.draw_text(240, 36,32,32, scd4.to_s, 1) if skill_cooldown4 > 10
  372. end
  373.  
  374. def update_cooldown
  375. if @on_map and @actor != $game_player.actor
  376. @actor = $game_player.actor
  377. refresh_icons
  378. refresh_texts
  379. end
  380.  
  381. if $game_player.refresh_skillbar > 0
  382. $game_player.refresh_skillbar -= 1
  383. if $game_player.refresh_skillbar == 0
  384. @actor.apply_usability
  385. refresh_icons
  386. end
  387. end
  388.  
  389. if cool_down_active?
  390. refresh_texts if @framer == 0
  391. @framer += 1; @framer = 0 if @framer == 10
  392. else
  393. @framer = 0
  394. end
  395. end
  396.  
  397. # if mouse exist update the mouse settings
  398. def update_mouse_tiles
  399. mx = (Mouse.pos[0] / 32) ; my = (Mouse.pos[1] / 32)
  400. case [mx, my]
  401. when [Tile_X, Tile_Y] then $game_player.mouse_over = 1
  402. when [Tile_X + 1, Tile_Y] then $game_player.mouse_over = 2
  403. when [Tile_X + 2, Tile_Y] then $game_player.mouse_over = 3
  404. when [Tile_X + 3, Tile_Y] then $game_player.mouse_over = 4
  405. when [Tile_X + 4, Tile_Y] then $game_player.mouse_over = 5
  406. when [Tile_X + 5, Tile_Y] then $game_player.mouse_over = 6
  407. when [Tile_X + 6, Tile_Y] then $game_player.mouse_over = 7
  408. when [Tile_X + 7, Tile_Y] then $game_player.mouse_over = 8
  409. when [Tile_X + 8, Tile_Y] then $game_player.mouse_over = 9
  410. else
  411. $game_player.mouse_over = 0 if $game_player.mouse_over != 0
  412. end
  413. if $game_player.mouse_over > 0
  414. create_mouse_blink
  415. update_mouse_blink_position
  416. @mouse_blink.opacity -= 3
  417. @mouse_blink.opacity = 70 if @mouse_blink.opacity <= 6
  418. else
  419. dispose_mouse_blink
  420. end
  421. end
  422.  
  423. # update mouse blink position
  424. def update_mouse_blink_position
  425. case $game_player.mouse_over
  426. when 1 then @mouse_blink.x = @layout.x + (5)
  427. when 2 then @mouse_blink.x = @layout.x + (5 + 32)
  428. when 3 then @mouse_blink.x = @layout.x + (5 + 64)
  429. when 4 then @mouse_blink.x = @layout.x + (5 + 96)
  430. when 5 then @mouse_blink.x = @layout.x + (5 + 128)
  431. when 6 then @mouse_blink.x = @layout.x + (5 + 160)
  432. when 7 then @mouse_blink.x = @layout.x + (5 + 192)
  433. when 8 then @mouse_blink.x = @layout.x + (5 + 224)
  434. when 9 then @mouse_blink.x = @layout.x + (5 + 256)
  435. end
  436. end
  437.  
  438. def create_mouse_blink
  439. return if !@mouse_blink.nil?
  440. @mouse_blink = ::Sprite.new(@view)
  441. @mouse_blink.bitmap = Bitmap.new(22, 22)
  442. @mouse_blink.bitmap.fill_rect(0, 0, 22, 22, Color.new(255,255,255))
  443. @mouse_blink.y = @layout.y + 8
  444. @mouse_blink.z = self.z
  445. @mouse_blink.opacity = 70
  446. end
  447.  
  448. def dispose_mouse_blink
  449. return if @mouse_blink.nil?
  450. @mouse_blink.dispose
  451. @mouse_blink = nil
  452. end
  453. #--------- end of mouse settings
  454.  
  455. def dispose
  456. self.bitmap.dispose
  457. @layout.bitmap.dispose
  458. @layout.dispose
  459. @icons.bitmap.dispose
  460. @icons.dispose
  461. @info_keys.bitmap.dispose
  462. @info_keys.dispose
  463. super
  464. end
  465.  
  466. def draw_icon(icon_index, x, y, enabled = true)
  467. bit = Cache.system("Iconset")
  468. rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  469. @icons.bitmap.blt(x, y, bit, rect, enabled ? 255 : 150)
  470. end
  471. end
Add Comment
Please, Sign In to add comment