Advertisement
Dekita

Item Popups v1.0

Mar 13th, 2014
653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.80 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Item Popups
  5. # -- Author : Dekita
  6. # -- Version : 1.0
  7. # -- Level : Easy / Normal
  8. # -- Requires : $D13x Core v2.3+
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:Item_Pops]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 13/o3/2o13 - Finished,
  21. # ??/??/2o13 - Started
  22. #
  23. #===============================================================================
  24. # ☆ Introduction
  25. #-------------------------------------------------------------------------------
  26. # This script creates an animated popup that is shown automatically when the
  27. # party's inventory is changed. It shows all item, weapon, armor and gold
  28. # gains && losses.
  29. #
  30. # You can also use script calls to change weather popups are displayed and to
  31. # turn on / off the popup feature.
  32. #
  33. #===============================================================================
  34. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  35. #===============================================================================
  36. # 1. You MUST give credit to "Dekita" !!
  37. # 2. You are NOT allowed to repost this script.(or modified versions)
  38. # 3. You are NOT allowed to convert this script.
  39. # 4. You are NOT allowed to use this script for Commercial games.
  40. # 5. ENJOY!
  41. #
  42. # "FINE PRINT"
  43. # By using this script you hereby agree to the above terms and conditions,
  44. # if any violation of the above terms occurs "legal action" may be taken.
  45. # Not understanding the above terms and conditions does NOT mean that
  46. # they do not apply to you.
  47. # If you wish to discuss the terms and conditions in further detail you can
  48. # contact me at http://dekitarpg.wordpress.com/
  49. #
  50. #===============================================================================
  51. # ☆ Instructions
  52. #-------------------------------------------------------------------------------
  53. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  54. #
  55. #===============================================================================
  56. # ☆ Script Calls
  57. #-------------------------------------------------------------------------------
  58. # make_popup(type, id, value)
  59. # type = :item, :weapon, :armor, :gold
  60. # id = item, weapon, armor id. if gold, leave 0 or nil
  61. # valu = the value shown in the popup.
  62. #
  63. #-------------------------------------------------------------------------------
  64. # $game_temp.item_pops_on?
  65. # Returns true / false depending on weather popups can be shown.
  66. #
  67. #-------------------------------------------------------------------------------
  68. # $game_temp.show_item_pops
  69. # Enables popups to be shown
  70. #
  71. #-------------------------------------------------------------------------------
  72. # $game_temp.hide_item_pops
  73. # Disables popups from being shown
  74. #
  75. #-------------------------------------------------------------------------------
  76. # $game_temp.alt_item_pops
  77. # Alternate Show/Hide Popups.
  78. #
  79. #===============================================================================
  80. # ☆ HELP
  81. #-------------------------------------------------------------------------------
  82. #
  83. #===============================================================================
  84. module Item_Popping
  85. #===============================================================================
  86. #-----------------------------------------------------------------------------
  87. # Position after offset slide.
  88. #-----------------------------------------------------------------------------
  89. X_Pos = 8 # X Position
  90. Y_Pos = 330 # Y Position
  91. #-----------------------------------------------------------------------------
  92. # Offset Slide happens before the item fadeout
  93. #-----------------------------------------------------------------------------
  94. X_Offset = 40 # X Slide
  95. Y_Offset = 0 # Y Slide
  96. #-----------------------------------------------------------------------------
  97. # Move happens during the item fadeout
  98. #-----------------------------------------------------------------------------
  99. X_Move = 0 # X Move Speed
  100. Y_Move = -1 # Y Move Speed
  101. #-----------------------------------------------------------------------------
  102. #
  103. #-----------------------------------------------------------------------------
  104. Init_Opacity = 0
  105. Fade_Speed = 2.5
  106. #-----------------------------------------------------------------------------
  107. #
  108. #-----------------------------------------------------------------------------
  109. Authority = 200
  110. #-----------------------------------------------------------------------------
  111. #
  112. #-----------------------------------------------------------------------------
  113. Font = ["VL Gothic", "Arial"]
  114. Font_Size = 16
  115. Font_Bold = true
  116. Font_Italic = false
  117. Value_Size = 12
  118. #-----------------------------------------------------------------------------
  119. #
  120. #-----------------------------------------------------------------------------
  121. Gold_Icon = [361,0] # [icon index, hue]
  122. Gold_Color = Text_Color::Gold
  123. #-----------------------------------------------------------------------------
  124. # Sound Fx - ['Sfx Name', volume, pitch]
  125. #-----------------------------------------------------------------------------
  126. Sound_Fx ={
  127. :item => ['Load' , 60, 100],
  128. :weapon => ['Equip1' , 60, 100],
  129. :armor => ['Equip1' , 60, 100],
  130. :gold => ['Shop' , 60, 100],
  131. }
  132. #####################
  133. # CUSTOMISATION END #
  134. end #####################
  135. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  136. # #
  137. # http://dekitarpg.wordpress.com/ #
  138. # #
  139. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  140. #===============================================================================#
  141. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  142. # YES?\.\. #
  143. # OMG, REALLY? \| #
  144. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  145. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  146. #===============================================================================#
  147. class Game_Interpreter
  148. #===============================================================================
  149. #-----------------------------------------------------------------------------
  150. #
  151. #-----------------------------------------------------------------------------
  152. alias :com125_popup :command_125
  153. alias :com126_popup :command_126
  154. alias :com127_popup :command_127
  155. alias :com128_popup :command_128
  156. #-----------------------------------------------------------------------------
  157. #
  158. #-----------------------------------------------------------------------------
  159. def command_125
  160. com125_popup
  161. value = operate_value(@params[0], @params[1], @params[2])
  162. make_popup(:gold,@params[0],value)
  163. end
  164. #-----------------------------------------------------------------------------
  165. #
  166. #-----------------------------------------------------------------------------
  167. def command_126
  168. com126_popup
  169. value = operate_value(@params[1], @params[2], @params[3])
  170. make_popup(:item,@params[0],value)
  171. end
  172. #-----------------------------------------------------------------------------
  173. #
  174. #-----------------------------------------------------------------------------
  175. def command_127
  176. com127_popup
  177. value = operate_value(@params[1], @params[2], @params[3])
  178. make_popup(:weapon,@params[0],value)
  179. end
  180. #-----------------------------------------------------------------------------
  181. #
  182. #-----------------------------------------------------------------------------
  183. def command_128
  184. com128_popup
  185. value = operate_value(@params[1], @params[2], @params[3])
  186. make_popup(:armor,@params[0],value)
  187. end
  188. #-----------------------------------------------------------------------------
  189. #
  190. #-----------------------------------------------------------------------------
  191. def make_popup(type,id,value)
  192. return unless $game_temp.item_pops_on?
  193. case type
  194. when :item then item = $data_items[id]
  195. when :weapon then item = $data_weapons[id]
  196. when :armor then item = $data_armors[id]
  197. when :gold then item = Popup_Gold.new
  198. end
  199. play_pop_noise(type)
  200. display_popup(item,value)
  201. end
  202. #-----------------------------------------------------------------------------
  203. #
  204. #-----------------------------------------------------------------------------
  205. def play_pop_noise(type)
  206. v = Item_Popping::Sound_Fx[type]
  207. Audio.se_play("Audio\\SE\\#{v[0]}",v[1],v[2])
  208. end
  209. #-----------------------------------------------------------------------------
  210. #
  211. #-----------------------------------------------------------------------------
  212. def display_popup(item,value)
  213. SceneManager.scene.spriteset.init_item_popups(item,value)
  214. end
  215. end
  216.  
  217. #===============================================================================
  218. class Game_Temp
  219. #===============================================================================
  220. #-----------------------------------------------------------------------------
  221. #
  222. #-----------------------------------------------------------------------------
  223. alias :init_itempopups :initialize
  224. #-----------------------------------------------------------------------------
  225. #
  226. #-----------------------------------------------------------------------------
  227. def initialize
  228. @can_popups = true
  229. init_itempopups
  230. end
  231. #-----------------------------------------------------------------------------
  232. #
  233. #-----------------------------------------------------------------------------
  234. def item_pops_on?
  235. @can_popups
  236. end
  237. #-----------------------------------------------------------------------------
  238. #
  239. #-----------------------------------------------------------------------------
  240. def show_item_pops
  241. @can_popups = true
  242. end
  243. #-----------------------------------------------------------------------------
  244. #
  245. #-----------------------------------------------------------------------------
  246. def hide_item_pops
  247. @can_popups = false
  248. end
  249. #-----------------------------------------------------------------------------
  250. #
  251. #-----------------------------------------------------------------------------
  252. def alt_item_pops
  253. @can_popups = !@can_popups
  254. end
  255. end
  256.  
  257. #===============================================================================
  258. class Popup_Gold
  259. #===============================================================================
  260. #-----------------------------------------------------------------------------
  261. #
  262. #-----------------------------------------------------------------------------
  263. attr_reader :name
  264. attr_reader :icon_hue
  265. attr_reader :icon_index
  266. attr_reader :item_disp_color
  267. #-----------------------------------------------------------------------------
  268. #
  269. #-----------------------------------------------------------------------------
  270. def initialize
  271. @name = Vocab.currency_unit
  272. @icon_hue = Item_Popping::Gold_Icon[1]
  273. @icon_index = Item_Popping::Gold_Icon[0]
  274. @item_disp_color = Item_Popping::Gold_Color
  275. end
  276. end
  277.  
  278. #===============================================================================
  279. class Sprite_PopItem < Sprite
  280. #===============================================================================
  281. #-----------------------------------------------------------------------------
  282. #
  283. #-----------------------------------------------------------------------------
  284. attr_reader :finished
  285. #-----------------------------------------------------------------------------
  286. # Initialize
  287. #-----------------------------------------------------------------------------
  288. def initialize(vp=nil,item=nil,amo=0)
  289. super(vp)
  290. self.z = Item_Popping::Authority
  291. self.x = Item_Popping::X_Pos - Item_Popping::X_Offset
  292. self.y = Item_Popping::Y_Pos - Item_Popping::Y_Offset
  293. self.opacity = Item_Popping::Init_Opacity
  294. self.bitmap = Bitmap.new(152,24)
  295. init_icon(item.icon_index,item.icon_hue)
  296. init_text(item)
  297. init_amount(item,amo)
  298. @starting = true
  299. @finished = false
  300. end
  301. #-----------------------------------------------------------------------------
  302. #
  303. #-----------------------------------------------------------------------------
  304. def init_icon(icon=0,hue=0)
  305. @icon = Cache.icon(IconEvents::Set,hue)
  306. rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
  307. self.bitmap.blt(0, 0, @icon, rect)
  308. @icon.dispose
  309. @icon = nil
  310. end
  311. #-----------------------------------------------------------------------------
  312. #
  313. #-----------------------------------------------------------------------------
  314. def init_text(item)
  315. self.bitmap.font.name = Item_Popping::Font
  316. self.bitmap.font.size = Item_Popping::Font_Size
  317. self.bitmap.font.bold = Item_Popping::Font_Bold
  318. self.bitmap.font.italic = Item_Popping::Font_Italic
  319. self.bitmap.font.color = item.item_disp_color
  320. self.bitmap.draw_text(24,-2,128,24, item.name)
  321. end
  322. #-----------------------------------------------------------------------------
  323. #
  324. #-----------------------------------------------------------------------------
  325. def init_amount(item,amount)
  326. self.bitmap.font.name = Item_Popping::Font
  327. self.bitmap.font.size = Item_Popping::Value_Size
  328. self.bitmap.font.bold = Item_Popping::Font_Bold
  329. self.bitmap.font.italic = Item_Popping::Font_Italic
  330. self.bitmap.font.color = item.item_disp_color
  331. amount > 0 ? amount = "+#{amount}" : "-#{amount}"
  332. self.bitmap.draw_text(20,8,128,24,amount)
  333. end
  334. #-----------------------------------------------------------------------------
  335. # Dispose
  336. #-----------------------------------------------------------------------------
  337. def dispose
  338. super
  339. if self.bitmap != nil
  340. self.bitmap.dispose
  341. end
  342. end
  343. #-----------------------------------------------------------------------------
  344. # Update
  345. #-----------------------------------------------------------------------------
  346. def update
  347. super
  348. if @starting
  349. self.x += 1 if self.x < Item_Popping::X_Pos
  350. else
  351. self.x += Item_Popping::X_Move
  352. end
  353. self.y += Item_Popping::Y_Move if !@starting
  354. if @starting
  355. self.opacity += (Item_Popping::Fade_Speed*2)
  356. @starting = false if self.opacity >= 255
  357. else
  358. self.opacity -= Item_Popping::Fade_Speed
  359. if self.opacity <= 0
  360. @finished = true
  361. end
  362. end
  363. end
  364. end
  365.  
  366. #===============================================================================
  367. module Spriteset_ItemPopup
  368. #===============================================================================
  369. #-----------------------------------------------------------------------------
  370. #
  371. #-----------------------------------------------------------------------------
  372. def load_itempop_data
  373. @item_pops = []
  374. end
  375. #-----------------------------------------------------------------------------
  376. #
  377. #-----------------------------------------------------------------------------
  378. def init_item_popups(item,amo=0)
  379. return unless amo != 0
  380. @item_pops << Sprite_PopItem.new(nil,item,amo)
  381. end
  382. #-----------------------------------------------------------------------------
  383. #
  384. #-----------------------------------------------------------------------------
  385. def disp_item_popups
  386. return unless @item_pops
  387. @item_pops.each do |i|
  388. next unless i.disposed?
  389. i.dispose
  390. end
  391. end
  392. #-----------------------------------------------------------------------------
  393. #
  394. #-----------------------------------------------------------------------------
  395. def updt_item_popups
  396. return unless @item_pops
  397. @item_pops.each do |i|
  398. disp = i.disposed?
  399. next if i.disposed?
  400. i.update
  401. i.dispose if i.finished
  402. end
  403. end
  404. end
  405.  
  406. #===============================================================================
  407. class Spriteset_Map
  408. #===============================================================================
  409. #-----------------------------------------------------------------------------
  410. # Included Modules
  411. #-----------------------------------------------------------------------------
  412. include Spriteset_ItemPopup
  413. #-----------------------------------------------------------------------------
  414. # Alias List
  415. #-----------------------------------------------------------------------------
  416. alias :popitem_initialize :initialize
  417. alias :popitem_dispose :dispose
  418. alias :popitem_update :update
  419. #-----------------------------------------------------------------------------
  420. # Initialize
  421. #-----------------------------------------------------------------------------
  422. def initialize
  423. popitem_initialize
  424. load_itempop_data
  425. end
  426. #-----------------------------------------------------------------------------
  427. # Dispose
  428. #-----------------------------------------------------------------------------
  429. def dispose
  430. disp_item_popups
  431. popitem_dispose
  432. end
  433. #-----------------------------------------------------------------------------
  434. # Update
  435. #-----------------------------------------------------------------------------
  436. def update
  437. updt_item_popups
  438. popitem_update
  439. end
  440. end
  441.  
  442. #===============================================================================
  443. class Spriteset_Battle
  444. #===============================================================================
  445. #-----------------------------------------------------------------------------
  446. # Included Modules
  447. #-----------------------------------------------------------------------------
  448. include Spriteset_ItemPopup
  449. #-----------------------------------------------------------------------------
  450. # Alias List
  451. #-----------------------------------------------------------------------------
  452. alias :popitem_initialize :initialize
  453. alias :popitem_dispose :dispose
  454. alias :popitem_update :update
  455. #-----------------------------------------------------------------------------
  456. # Initialize
  457. #-----------------------------------------------------------------------------
  458. def initialize
  459. popitem_initialize
  460. load_itempop_data
  461. end
  462. #-----------------------------------------------------------------------------
  463. # Dispose
  464. #-----------------------------------------------------------------------------
  465. def dispose
  466. disp_item_popups
  467. popitem_dispose
  468. end
  469. #-----------------------------------------------------------------------------
  470. # Update
  471. #-----------------------------------------------------------------------------
  472. def update
  473. updt_item_popups
  474. popitem_update
  475. end
  476. end
  477.  
  478. #===============================================================================
  479. class Scene_Map < Scene_Base
  480. #===============================================================================
  481. #-----------------------------------------------------------------------------
  482. #
  483. #-----------------------------------------------------------------------------
  484. attr_reader :spriteset
  485. end
  486.  
  487. #===============================================================================
  488. class Scene_Battle < Scene_Base
  489. #===============================================================================
  490. #-----------------------------------------------------------------------------
  491. #
  492. #-----------------------------------------------------------------------------
  493. attr_reader :spriteset
  494. end
  495.  
  496. #==============================================================================#
  497. # http://dekitarpg.wordpress.com/ #
  498. #==============================================================================#
  499. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement