pigu_6

VM | POP UP ITEM

Apr 19th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.31 KB | None | 0 0
  1. #Sleek Item Popup v1.4
  2. #----------#
  3. #
  4. #Como usarlo:
  5. # Se pone el evento "Llamar script" y se completa el siguiente cuadro
  6. # popup(Categoria, Item , Cantidad, Tiempo)
  7. #
  8. # Categoria varia entre 0, 1 y 2 (0 = Items, 1 = Armas, 2 = Armaduras)
  9. # Item: Se pone el ID del item que queramos que aparezca
  10. # Cantidad: Se pone la cantidad de items que se consiguen
  11. # Tiempo: Es el tiempo que quieren que dure el popup (esto es opcional)
  12. #
  13. #Ejemplos:
  14. # popup(1,1,1) Va a aparecer el icono y nombre de la pocion +1
  15. # popup(1,1,1,120) lo mismo que antes nada mas que ahora el popup dura 120frames
  16. #
  17. #
  18. #Customization: Just the Sound Effect, set to nil for no sound effect
  19. #
  20. #----------#
  21. #-- Script by: V.M of D.T
  22. #--- Free to use in any non-commercial project with credit given
  23.  
  24. #Sound effect played on popup: # "Filename", Volume(0-100), Pitch(50-150)
  25. PU_SOUND_EFFECT = ["Item3",100,50]
  26.  
  27. #Duration in frames of Item Popup fadein and fadeout
  28. PU_FADEIN_TIME = 30
  29. PU_FADEOUT_TIME = 30
  30.  
  31. #Default duration of the popup
  32. PU_DEFAULT_DURATION = 90
  33.  
  34. #Whether to use a custom or default font
  35. PU_USE_CUSTOM_FONT = false
  36.  
  37. #Settings for custom item popup font
  38. PU_DEFAULT_FONT_NAME = ["Verdana"]
  39. PU_DEFAULT_FONT_SIZE = 24
  40. PU_DEFAULT_FONT_COLOR = Color.new(255,255,255,255)
  41. PU_DEFAULT_FONT_BOLD = false
  42. PU_DEFAULT_FONT_ITALIC = false
  43. PU_DEFAULT_FONT_SHADOW = false
  44. PU_DEFAULT_FONT_OUTLINE = true
  45.  
  46. class Item_Popup < Window_Base
  47. def initialize(item, amount, duration, nosound)
  48. super(0,0,100,96)
  49. Audio.se_play('Audio/SE/' + PU_SOUND_EFFECT[0],PU_SOUND_EFFECT[1],PU_SOUND_EFFECT[2]) unless PU_SOUND_EFFECT.nil? or nosound
  50. self.opacity = 0
  51. self.x = $game_player.screen_x - 16
  52. self.y = $game_player.screen_y - 80
  53. @duration = 90
  54. @item = item
  55. @amount = amount
  56. @amount = "+" + @amount.to_s if @amount > 0
  57. @name = item.name.clone
  58. @text = ""
  59. @timer = 0
  60. @split = (PU_FADEIN_TIME) / @name.size
  61. @split = 2 if @split < 2
  62. amount > 0 ? @red = false : @red = true
  63. contents.font.size = 16
  64. textsize = text_size(@name)
  65. self.width = textsize.width + 54
  66. self.height = textsize.height + 54
  67. self.x -= self.width / 4
  68. create_contents
  69. if PU_USE_CUSTOM_FONT
  70. contents.font.name = PU_DEFAULT_FONT_NAME
  71. contents.font.size = PU_DEFAULT_FONT_SIZE
  72. contents.font.color = PU_DEFAULT_FONT_COLOR
  73. contents.font.bold = PU_DEFAULT_FONT_BOLD
  74. contents.font.italic = PU_DEFAULT_FONT_ITALIC
  75. contents.font.shadow = PU_DEFAULT_FONT_SHADOW
  76. contents.font.outline = PU_DEFAULT_FONT_OUTLINE
  77. end
  78. self.contents_opacity = 0
  79. update
  80. end
  81. def update
  82. super
  83. self.visible = true if !self.visible
  84. self.x = $game_player.screen_x - 16
  85. self.y = $game_player.screen_y - 80
  86. self.x -= self.width / 4
  87. open if @timer < (PU_FADEIN_TIME)
  88. close if @timer > (PU_FADEOUT_TIME + @duration)
  89. @timer += 1
  90. @text += @name.slice!(0,1) if @timer % @split == 0
  91. contents.clear
  92. contents.font.size = 16
  93. @red ? color = Color.new(255,0,0) : color = Color.new(0,255,0)
  94. contents.font.color = color
  95. draw_text(contents.width / 4 + 16,24,36,24,@amount)
  96. contents.font.color = Font.default_color
  97. contents.font.size = 14
  98. draw_text(0,0,contents.width,contents.height,@text)
  99. draw_icon(102,contents.width / 4 - 12,24)
  100. draw_icon(@item.icon_index,contents.width / 4 - 12,24)
  101. end
  102. def close
  103. self.contents_opacity -= (255 / (PU_FADEOUT_TIME))
  104. end
  105. def open
  106. self.contents_opacity += (255 / (PU_FADEIN_TIME))
  107. end
  108. end
  109.  
  110. class Game_Interpreter
  111. def popup(type,item,amount,duration = PU_DEFAULT_DURATION,nosound = false)
  112. data = $data_items[item] if type == 0
  113. data = $data_weapons[item] if type == 1
  114. data = $data_armors[item] if type == 2
  115. $popupwindow = Item_Popup.new(data,amount,duration,nosound)
  116. end
  117. end
  118.  
  119.  
  120. class Scene_Map
  121. alias popup_update update
  122. alias popup_preterminate pre_terminate
  123. def update
  124. popup_update
  125. return if $popupwindow.nil?
  126. $popupwindow.update
  127. $popupwindow = nil if $popupwindow.opacity < 0
  128. end
  129. def pre_terminate
  130. popup_preterminate
  131. $popupwindow.visible = false unless $popupwindow.nil?
  132. end
  133. end
Advertisement
Add Comment
Please, Sign In to add comment