Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.20 KB | None | 0 0
  1. #==============================================================================
  2. # Chest Item Pop-Up 2
  3. #==============================================================================
  4. # Author : OriginalWij
  5. # Version : 1.2
  6. #==============================================================================
  7.  
  8. #==============================================================================
  9. # NOTE: The newest version is the ONLY supported version!
  10. #
  11. # v1.2
  12. # - Added Experience popup for event commands
  13. #==============================================================================
  14.  
  15. #==============================================================================
  16. # To use:
  17. #
  18. # 1) Setup the options in configuration section below
  19. # 2) Turn on the activation switch (defined in configuration section below)
  20. # 3) Add items via event commands like normal
  21. #
  22. # NOTE1: this script will automatically pop-up if activation switch is on!
  23. # NOTE2: turn activation switch OFF to add items WITHOUT popup
  24. # NOTE3: when adding multiple (different) items, insert a WAIT(1) between them
  25. # NOTE4: use WAIT(7) between a message & popup (allows message window to close)
  26. #==============================================================================
  27.  
  28. #==============================================================================
  29. # To call manually from any scene or from an event script command:
  30. #
  31. # NOTE: For scripters only!
  32. #
  33. # (useful if using a break-limits script and popping-up 100+ of one item)
  34. #
  35. # $scene.item_popup(type, amount, index)
  36. # $scene.item_popup(type, amount, index, add)
  37. # type : 0 :gold; 1 :items; 2 :weapons; 3 :armor; 4 :experience
  38. # amount : quantity "gaining"
  39. # index : item ID (use 0 for gold & experience)
  40. # add : adds items into inventory if true (optional, default = false)
  41. #==============================================================================
  42.  
  43. #==============================================================================
  44. # Config
  45. #==============================================================================
  46.  
  47. module OW_CHEST
  48. # Switch to activate/deactivate item pop-ups (switch ID)
  49. POPUP_SWITCH = 5
  50. # Pop-up speed [0 = fastest ... 4 = slowest]
  51. POPUP_SPEED = 4
  52. # Show item icon in item description? ('gold' icon is always shown)
  53. SHOW_DESC_ICON = true
  54. # Pop-up item description? [false = static description window]
  55. POPUP_DESC = true
  56.  
  57. # "Gold" icon (icon ID)
  58. GOLD_ICON = 205
  59.  
  60. # Play sound on popup?
  61. PLAY_SOUND = true
  62. # Sound to play upon popup [if PLAY_SOUND = true]
  63. S_NAME = 'Audio/SE/Chime2'
  64. S_VOLUME = 100
  65. S_PITCH = 150
  66.  
  67. # Wait for button to close? [false = wait for time]
  68. BUTTON_WAIT = true
  69. # Buttons to wait for [if BUTTON_WAIT = true] (buttons can be the same)
  70. BUTTON_1 = Input::C
  71. BUTTON_2 = Input::B
  72. # Frames to wait [if BUTTON_WAIT = false] (in frames)
  73. TIME = 120
  74.  
  75. # Popup items & gold at the end of battle?
  76. BATTLE_POP = true
  77.  
  78. # Popup experience gained? [in battle also if BATTLE_POP = true]
  79. XP_POP = true
  80. # Experience icon to show [if XP_POP = true] (icon ID)
  81. XP_ICON = 27
  82. end
  83.  
  84. #==============================================================================
  85. # End Config
  86. #==============================================================================
  87.  
  88. ###########################################################################
  89. # Do NOT modify ANYTHING below unless you know what you're doing!!! #
  90. # Failure to do so may result in hair-loss, blindness, or insanity! #
  91. ###########################################################################
  92.  
  93. #==============================================================================
  94. # Game_Interpreter
  95. #==============================================================================
  96.  
  97. class Game_Interpreter
  98. #--------------------------------------------------------------------------
  99. # Command 125 [Change Gold] [Mod]
  100. #--------------------------------------------------------------------------
  101. alias ow_chest_command_125 command_125 unless $@
  102. def command_125
  103. value = operate_value(@params[0], @params[1], @params[2])
  104. if $game_switches[OW_CHEST::POPUP_SWITCH] and @params[0] == 0
  105. $scene.item_popup(0, value, 1)
  106. end
  107. ow_chest_command_125
  108. end
  109. #--------------------------------------------------------------------------
  110. # Command 126 [Change Items] [Mod]
  111. #--------------------------------------------------------------------------
  112. alias ow_chest_command_126 command_126 unless $@
  113. def command_126
  114. value = operate_value(@params[1], @params[2], @params[3])
  115. if $game_switches[OW_CHEST::POPUP_SWITCH] and @params[1] == 0
  116. $scene.item_popup(1, value, @params[0])
  117. end
  118. ow_chest_command_126
  119. end
  120. #--------------------------------------------------------------------------
  121. # Command 127 [Change Weapons] [Mod]
  122. #--------------------------------------------------------------------------
  123. alias ow_chest_command_127 command_127 unless $@
  124. def command_127
  125. value = operate_value(@params[1], @params[2], @params[3])
  126. if $game_switches[OW_CHEST::POPUP_SWITCH] and @params[1] == 0
  127. $scene.item_popup(2, value, @params[0])
  128. end
  129. ow_chest_command_127
  130. end
  131. #--------------------------------------------------------------------------
  132. # Command 128 [Change Armor] [Mod]
  133. #--------------------------------------------------------------------------
  134. alias ow_chest_command_128 command_128 unless $@
  135. def command_128
  136. value = operate_value(@params[1], @params[2], @params[3])
  137. if $game_switches[OW_CHEST::POPUP_SWITCH] and @params[1] == 0
  138. $scene.item_popup(3, value, @params[0])
  139. end
  140. ow_chest_command_128
  141. end
  142. #--------------------------------------------------------------------------
  143. # Command 315 [Change EXP] [Mod]
  144. #--------------------------------------------------------------------------
  145. alias ow_chest_command_315 command_315 unless $@
  146. def command_315
  147. value = operate_value(@params[1], @params[2], @params[3])
  148. if $game_switches[OW_CHEST::POPUP_SWITCH] and @params[1] == 0 and
  149. OW_CHEST::XP_POP
  150. $scene.item_popup(4, value, 0)
  151. end
  152. ow_chest_command_315
  153. end
  154. end
  155.  
  156. #==============================================================================
  157. # Scene_Base
  158. #==============================================================================
  159.  
  160. class Scene_Base
  161. #--------------------------------------------------------------------------
  162. # Basic Update Processing [New]
  163. #--------------------------------------------------------------------------
  164. def update_basic
  165. Graphics.update
  166. Input.update
  167. $game_map.update
  168. @spriteset.update unless @spriteset.nil?
  169. end
  170. #--------------------------------------------------------------------------
  171. # Item Pop-Up [New]
  172. #--------------------------------------------------------------------------
  173. def item_popup(type, amount, index, add = false)
  174. case type
  175. when 0 # Gold
  176. $game_party.gain_gold(amount) if add
  177. item = nil
  178. when 1 # Items
  179. $game_party.gain_item($data_items[index], amount) if add
  180. item = $data_items[index]
  181. when 2 # Weapons
  182. $game_party.gain_item($data_weapons[index], amount) if add
  183. item = $data_weapons[index]
  184. when 3 # Armors
  185. $game_party.gain_item($data_armors[index], amount) if add
  186. item = $data_armors[index]
  187. when 4 # Xp (no add)
  188. item = nil
  189. end
  190. icon = (item == nil) ? OW_CHEST::GOLD_ICON : item.icon_index
  191. icon = OW_CHEST::XP_ICON if type == 4
  192. x = $game_player.screen_x - 26
  193. y = $game_player.screen_y - 48
  194. @popup_window = Window_Base.new(x, y, 56, 56)
  195. @popup_window.opacity = @popup_window.contents_opacity = 0
  196. if $game_temp.in_battle
  197. @popup_window.x = (Graphics.width - @popup_window.width) / 2
  198. @popup_window.y = Graphics.height / 2 - 64
  199. end
  200. @popup_window.draw_icon(icon, 0, 0)
  201. max = OW_CHEST::POPUP_SPEED * 4 + 16
  202. for i in 1..max
  203. @popup_window.contents_opacity = i * (256 / max)
  204. @popup_window.y -= (32 / max)
  205. @popup_window.update
  206. update_basic
  207. end
  208. if OW_CHEST::PLAY_SOUND
  209. Audio.se_play(OW_CHEST::S_NAME, OW_CHEST::S_VOLUME, OW_CHEST::S_PITCH)
  210. end
  211. text = (item == nil) ? amount.to_s : item.name
  212. prefix_text = (amount == 1 or item == nil) ? "" : amount.to_s + " x "
  213. width = @popup_window.contents.text_size(text).width + 28
  214. prefix_width = @popup_window.contents.text_size(prefix_text).width
  215. x = (Graphics.width - (width + prefix_width + 32)) / 2
  216. y = (Graphics.height - 56) / 2
  217. y += 32 if OW_CHEST::POPUP_DESC
  218. @name_window = Window_Base.new(x, y, width + prefix_width + 32, 56)
  219. @name_window.opacity = @name_window.contents_opacity = 0
  220. unless item == nil
  221. w = width + prefix_width
  222. if OW_CHEST::SHOW_DESC_ICON
  223. @name_window.contents.draw_text(0, 0, w, 24, prefix_text)
  224. @name_window.draw_item_name(item, prefix_width, 0)
  225. else
  226. @name_window.contents.draw_text(14, 0, w, 24, prefix_text)
  227. @name_window.contents.draw_text(prefix_width + 14, 0, w, 24, item.name)
  228. end
  229. else
  230. @name_window.contents.draw_text(2, 0, width, 24, text)
  231. @name_window.draw_icon(icon, width - 24, 0)
  232. end
  233. for i in 1..max
  234. @name_window.y -= (32 / max) if OW_CHEST::POPUP_DESC
  235. @name_window.contents_opacity = i * (256 / max)
  236. @name_window.opacity = i * (256 / max)
  237. @name_window.update
  238. update_basic
  239. end
  240. count = 0
  241. loop do
  242. update_basic
  243. count += 1 unless OW_CHEST::BUTTON_WAIT
  244. break if Input.trigger?(OW_CHEST::BUTTON_1) and OW_CHEST::BUTTON_WAIT
  245. break if Input.trigger?(OW_CHEST::BUTTON_2) and OW_CHEST::BUTTON_WAIT
  246. break if count == OW_CHEST::TIME and !OW_CHEST::BUTTON_WAIT
  247. end
  248. for i in 1..max
  249. @popup_window.contents_opacity = 256 - i * (256 / max)
  250. @name_window.opacity = 256 - i * (256 / max)
  251. @name_window.contents_opacity = 256 - i * (256 / max)
  252. @popup_window.update
  253. @name_window.update
  254. update_basic
  255. end
  256. @popup_window.dispose
  257. @name_window.dispose
  258. Input.update
  259. end
  260. end
  261.  
  262. #==============================================================================
  263. # Scene_Battle
  264. #==============================================================================
  265.  
  266. class Scene_Battle < Scene_Base
  267. #--------------------------------------------------------------------------
  268. # Display Gained Experience and Gold [Mod]
  269. #--------------------------------------------------------------------------
  270. alias ow_chest_display_exp_and_gold display_exp_and_gold unless $@
  271. def display_exp_and_gold
  272. if OW_CHEST::BATTLE_POP and $game_switches[OW_CHEST::POPUP_SWITCH]
  273. exp = $game_troop.exp_total
  274. gold = $game_troop.gold_total
  275. if exp > 0 and !OW_CHEST::XP_POP
  276. text = sprintf(Vocab::ObtainExp, exp)
  277. $game_message.texts.push('\.' + text)
  278. wait_for_message
  279. elsif exp > 0 and OW_CHEST::XP_POP
  280. item_popup(4, exp, 0)
  281. end
  282. item_popup(0, gold, 0, true)
  283. else
  284. ow_chest_display_exp_and_gold
  285. end
  286. end
  287. #--------------------------------------------------------------------------
  288. # Display Gained Drop Items [Mod]
  289. #--------------------------------------------------------------------------
  290. alias ow_chest_display_drop_items display_drop_items unless $@
  291. def display_drop_items
  292. if OW_CHEST::BATTLE_POP and $game_switches[OW_CHEST::POPUP_SWITCH]
  293. drop_items = $game_troop.make_drop_items
  294. for item in drop_items
  295. type = 1 if item.is_a?(RPG::Item)
  296. type = 2 if item.is_a?(RPG::Weapon)
  297. type = 3 if item.is_a?(RPG::Armor)
  298. item_popup(type, 1, item.id, true)
  299. end
  300. else
  301. ow_chest_display_drop_items
  302. end
  303. end
  304. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement