Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Chest Item Pop-Up 2
- #==============================================================================
- # Author : OriginalWij
- # Version : 1.2
- #==============================================================================
- #==============================================================================
- # NOTE: The newest version is the ONLY supported version!
- #
- # v1.2
- # - Added Experience popup for event commands
- #==============================================================================
- #==============================================================================
- # To use:
- #
- # 1) Setup the options in configuration section below
- # 2) Turn on the activation switch (defined in configuration section below)
- # 3) Add items via event commands like normal
- #
- # NOTE1: this script will automatically pop-up if activation switch is on!
- # NOTE2: turn activation switch OFF to add items WITHOUT popup
- # NOTE3: when adding multiple (different) items, insert a WAIT(1) between them
- # NOTE4: use WAIT(7) between a message & popup (allows message window to close)
- #==============================================================================
- #==============================================================================
- # To call manually from any scene or from an event script command:
- #
- # NOTE: For scripters only!
- #
- # (useful if using a break-limits script and popping-up 100+ of one item)
- #
- # $scene.item_popup(type, amount, index)
- # $scene.item_popup(type, amount, index, add)
- # type : 0 :gold; 1 :items; 2 :weapons; 3 :armor; 4 :experience
- # amount : quantity "gaining"
- # index : item ID (use 0 for gold & experience)
- # add : adds items into inventory if true (optional, default = false)
- #==============================================================================
- #==============================================================================
- # Config
- #==============================================================================
- module OW_CHEST
- # Switch to activate/deactivate item pop-ups (switch ID)
- POPUP_SWITCH = 5
- # Pop-up speed [0 = fastest ... 4 = slowest]
- POPUP_SPEED = 4
- # Show item icon in item description? ('gold' icon is always shown)
- SHOW_DESC_ICON = true
- # Pop-up item description? [false = static description window]
- POPUP_DESC = true
- # "Gold" icon (icon ID)
- GOLD_ICON = 205
- # Play sound on popup?
- PLAY_SOUND = true
- # Sound to play upon popup [if PLAY_SOUND = true]
- S_NAME = 'Audio/SE/Chime2'
- S_VOLUME = 100
- S_PITCH = 150
- # Wait for button to close? [false = wait for time]
- BUTTON_WAIT = true
- # Buttons to wait for [if BUTTON_WAIT = true] (buttons can be the same)
- BUTTON_1 = Input::C
- BUTTON_2 = Input::B
- # Frames to wait [if BUTTON_WAIT = false] (in frames)
- TIME = 120
- # Popup items & gold at the end of battle?
- BATTLE_POP = true
- # Popup experience gained? [in battle also if BATTLE_POP = true]
- XP_POP = true
- # Experience icon to show [if XP_POP = true] (icon ID)
- XP_ICON = 27
- end
- #==============================================================================
- # End Config
- #==============================================================================
- ###########################################################################
- # Do NOT modify ANYTHING below unless you know what you're doing!!! #
- # Failure to do so may result in hair-loss, blindness, or insanity! #
- ###########################################################################
- #==============================================================================
- # Game_Interpreter
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # Command 125 [Change Gold] [Mod]
- #--------------------------------------------------------------------------
- alias ow_chest_command_125 command_125 unless $@
- def command_125
- value = operate_value(@params[0], @params[1], @params[2])
- if $game_switches[OW_CHEST::POPUP_SWITCH] and @params[0] == 0
- $scene.item_popup(0, value, 1)
- end
- ow_chest_command_125
- end
- #--------------------------------------------------------------------------
- # Command 126 [Change Items] [Mod]
- #--------------------------------------------------------------------------
- alias ow_chest_command_126 command_126 unless $@
- def command_126
- value = operate_value(@params[1], @params[2], @params[3])
- if $game_switches[OW_CHEST::POPUP_SWITCH] and @params[1] == 0
- $scene.item_popup(1, value, @params[0])
- end
- ow_chest_command_126
- end
- #--------------------------------------------------------------------------
- # Command 127 [Change Weapons] [Mod]
- #--------------------------------------------------------------------------
- alias ow_chest_command_127 command_127 unless $@
- def command_127
- value = operate_value(@params[1], @params[2], @params[3])
- if $game_switches[OW_CHEST::POPUP_SWITCH] and @params[1] == 0
- $scene.item_popup(2, value, @params[0])
- end
- ow_chest_command_127
- end
- #--------------------------------------------------------------------------
- # Command 128 [Change Armor] [Mod]
- #--------------------------------------------------------------------------
- alias ow_chest_command_128 command_128 unless $@
- def command_128
- value = operate_value(@params[1], @params[2], @params[3])
- if $game_switches[OW_CHEST::POPUP_SWITCH] and @params[1] == 0
- $scene.item_popup(3, value, @params[0])
- end
- ow_chest_command_128
- end
- #--------------------------------------------------------------------------
- # Command 315 [Change EXP] [Mod]
- #--------------------------------------------------------------------------
- alias ow_chest_command_315 command_315 unless $@
- def command_315
- value = operate_value(@params[1], @params[2], @params[3])
- if $game_switches[OW_CHEST::POPUP_SWITCH] and @params[1] == 0 and
- OW_CHEST::XP_POP
- $scene.item_popup(4, value, 0)
- end
- ow_chest_command_315
- end
- end
- #==============================================================================
- # Scene_Base
- #==============================================================================
- class Scene_Base
- #--------------------------------------------------------------------------
- # Basic Update Processing [New]
- #--------------------------------------------------------------------------
- def update_basic
- Graphics.update
- Input.update
- $game_map.update
- @spriteset.update unless @spriteset.nil?
- end
- #--------------------------------------------------------------------------
- # Item Pop-Up [New]
- #--------------------------------------------------------------------------
- def item_popup(type, amount, index, add = false)
- case type
- when 0 # Gold
- $game_party.gain_gold(amount) if add
- item = nil
- when 1 # Items
- $game_party.gain_item($data_items[index], amount) if add
- item = $data_items[index]
- when 2 # Weapons
- $game_party.gain_item($data_weapons[index], amount) if add
- item = $data_weapons[index]
- when 3 # Armors
- $game_party.gain_item($data_armors[index], amount) if add
- item = $data_armors[index]
- when 4 # Xp (no add)
- item = nil
- end
- icon = (item == nil) ? OW_CHEST::GOLD_ICON : item.icon_index
- icon = OW_CHEST::XP_ICON if type == 4
- x = $game_player.screen_x - 26
- y = $game_player.screen_y - 48
- @popup_window = Window_Base.new(x, y, 56, 56)
- @popup_window.opacity = @popup_window.contents_opacity = 0
- if $game_temp.in_battle
- @popup_window.x = (Graphics.width - @popup_window.width) / 2
- @popup_window.y = Graphics.height / 2 - 64
- end
- @popup_window.draw_icon(icon, 0, 0)
- max = OW_CHEST::POPUP_SPEED * 4 + 16
- for i in 1..max
- @popup_window.contents_opacity = i * (256 / max)
- @popup_window.y -= (32 / max)
- @popup_window.update
- update_basic
- end
- if OW_CHEST::PLAY_SOUND
- Audio.se_play(OW_CHEST::S_NAME, OW_CHEST::S_VOLUME, OW_CHEST::S_PITCH)
- end
- text = (item == nil) ? amount.to_s : item.name
- prefix_text = (amount == 1 or item == nil) ? "" : amount.to_s + " x "
- width = @popup_window.contents.text_size(text).width + 28
- prefix_width = @popup_window.contents.text_size(prefix_text).width
- x = (Graphics.width - (width + prefix_width + 32)) / 2
- y = (Graphics.height - 56) / 2
- y += 32 if OW_CHEST::POPUP_DESC
- @name_window = Window_Base.new(x, y, width + prefix_width + 32, 56)
- @name_window.opacity = @name_window.contents_opacity = 0
- unless item == nil
- w = width + prefix_width
- if OW_CHEST::SHOW_DESC_ICON
- @name_window.contents.draw_text(0, 0, w, 24, prefix_text)
- @name_window.draw_item_name(item, prefix_width, 0)
- else
- @name_window.contents.draw_text(14, 0, w, 24, prefix_text)
- @name_window.contents.draw_text(prefix_width + 14, 0, w, 24, item.name)
- end
- else
- @name_window.contents.draw_text(2, 0, width, 24, text)
- @name_window.draw_icon(icon, width - 24, 0)
- end
- for i in 1..max
- @name_window.y -= (32 / max) if OW_CHEST::POPUP_DESC
- @name_window.contents_opacity = i * (256 / max)
- @name_window.opacity = i * (256 / max)
- @name_window.update
- update_basic
- end
- count = 0
- loop do
- update_basic
- count += 1 unless OW_CHEST::BUTTON_WAIT
- break if Input.trigger?(OW_CHEST::BUTTON_1) and OW_CHEST::BUTTON_WAIT
- break if Input.trigger?(OW_CHEST::BUTTON_2) and OW_CHEST::BUTTON_WAIT
- break if count == OW_CHEST::TIME and !OW_CHEST::BUTTON_WAIT
- end
- for i in 1..max
- @popup_window.contents_opacity = 256 - i * (256 / max)
- @name_window.opacity = 256 - i * (256 / max)
- @name_window.contents_opacity = 256 - i * (256 / max)
- @popup_window.update
- @name_window.update
- update_basic
- end
- @popup_window.dispose
- @name_window.dispose
- Input.update
- end
- end
- #==============================================================================
- # Scene_Battle
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # Display Gained Experience and Gold [Mod]
- #--------------------------------------------------------------------------
- alias ow_chest_display_exp_and_gold display_exp_and_gold unless $@
- def display_exp_and_gold
- if OW_CHEST::BATTLE_POP and $game_switches[OW_CHEST::POPUP_SWITCH]
- exp = $game_troop.exp_total
- gold = $game_troop.gold_total
- if exp > 0 and !OW_CHEST::XP_POP
- text = sprintf(Vocab::ObtainExp, exp)
- $game_message.texts.push('\.' + text)
- wait_for_message
- elsif exp > 0 and OW_CHEST::XP_POP
- item_popup(4, exp, 0)
- end
- item_popup(0, gold, 0, true)
- else
- ow_chest_display_exp_and_gold
- end
- end
- #--------------------------------------------------------------------------
- # Display Gained Drop Items [Mod]
- #--------------------------------------------------------------------------
- alias ow_chest_display_drop_items display_drop_items unless $@
- def display_drop_items
- if OW_CHEST::BATTLE_POP and $game_switches[OW_CHEST::POPUP_SWITCH]
- drop_items = $game_troop.make_drop_items
- for item in drop_items
- type = 1 if item.is_a?(RPG::Item)
- type = 2 if item.is_a?(RPG::Weapon)
- type = 3 if item.is_a?(RPG::Armor)
- item_popup(type, 1, item.id, true)
- end
- else
- ow_chest_display_drop_items
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement