VX 스크립트

#==============================================================================
# Chest Item Pop-Up
#==============================================================================
# Author  : OriginalWij
# Version : 3.0
#==============================================================================

#==============================================================================
# v1.0
# - Initial release
# v1.1
# - Added description window
# v1.2
# - Bug fix and added forgotten aliases
# v1.3
# - Added option to only popup once for many of the same item
# v2.0
# - Reworked name popup window (won't show "1 x" if only one item)
# - Reworked gold display (more efficient)
# - Added option to turn popup sound on/off
# - Added option to turn popup text on/off
# - Added icon to name popup and the ability to turn it on/off
# - Added adjustable X & Y coordinates for name popup window
# - Added "call" feature - with and without adding the item to inventory
# - Added option to wait for button or time for popup name window
# - Added options to define button and time for popup name window wait
# - Added option to enable/disable the "close window" sound
# - Added options to define "close window" sound
# v2.1
# - Fixed moving event bug
# - Added option to have popup always active
# - Added option for overlay graphic
# - Added auto-adjust name window location, depending on actor X/Y
# v2.2
# - Several minor (non-bug) display fixes
# - Removed overlay option due to compatibility problems
# - Optimized script
# v3.0
# - Bugfix for when called from a common event
# - Reworked main popup scene for new X/Y determination
# - Added option for 2nd window cancellation button
# - Added option to center the text window or auto-move to not cover the player
# - Added option to popup items & gold after battle
#==============================================================================

#==============================================================================
# To use:
#
#   Normal Mode    : turn on the switch (designated below) BEFORE
#                    each gold/item addition
#   Automatic Mode : turn on the switch (designated below) if you DON'T want
#                    popups and then turn the switch off when done
#
# To call manually:
#
#   (useful if using a break-limits script and popping-up 100+ of one item)
#
#   $scene = Chest_Popup.new(type, amount, index, add = false, x = pX, y = pY)
#          type : 0 :gold, 1 :items, 2 :weapons, 3 :armor
#        amount : number of items "gaining"
#         index : item ID
#           add : adds item(s) shown into inventory if true (default = false)
#             x : custom X coordinate to pop-up at (default = player X)
#             y : custom Y coordinate to pop-up at (default = player Y)
#==============================================================================

#==============================================================================
# NOTE: when adding multiple (different) items in an event, insert a WAIT(1)
#       between them (insert the WAIT(1) even if in AUTOMATIC mode)
#==============================================================================
# NOTE: the switch turns itself off after each "add item/gold" event command
#       UNLESS in automatic mode (you MUST turn it off MANUALLY in auto-mode)
#==============================================================================
# NOTE: insert a WAIT(7) between a text message and adding items in events
#       (allows time for the message window to close)
#==============================================================================

  # Automatic popup mode
  # (true = ALWAYS popup UNLESS $game_switches[POPUP_SWITCH] is on)
  AUTO_POPUP = true
  # Switch to activate/deactivate popups
  # (activate if AUTO_POPUP = false) (deactivate if AUTO_POPUP = true)
  POPUP_SWITCH = 1
  # "Gold" icon index
  GOLD_ICON = 205
  # Only popup once (if many of the same item)
  ONLY_SHOW_ONE = true
  # Popup gold/items gained in battle (pops-up after battle)
  BATTLE_POP = true
    # Battle reward prefix text for popup text window
    # (if BATTLE_POP = true)
    BATTLE_REWARD = 'Battle Reward: '
   
  # Play sound on popup?
  PLAY_P_SND = true
    #######################################################
    # 3 options below are valid ONLY if PLAY_P_SND = true #
    #######################################################
    # Sound to play upon popup
    P_SND = 'Audio/SE/Chime2'
    P_SND_V = 100
    P_SND_P = 150
   
  # Play "close window" sound?
  PLAY_C_SND = true
    #######################################################
    # 3 options below are valid ONLY if PLAY_C_SND = true #
    #######################################################
    # Sound to play upon popup close
    C_SND = 'Audio/SE/Cancel'
    C_SND_V = 80
    C_SND_P = 100
   
  # Show popup text?
  SHOW_POPUP_TEXT = true
    ##############################################################
    # ALL options below are valid ONLY if SHOW_POPUP_TEXT = true #
    ##############################################################
    # Show icon with popup text?
    SHOW_POPUP_TEXT_ICON = true
    # Auto adjust window if over player
    TEXT_WINDOW_MOVE = true
    # Popup text window Y coordinate
    TEXT_WINDOW_Y = 180
    # Popup text window X coordinate offset
    # 0 (Zero)         : centered in the window
    # negative integer : offset left  (centered)
    # positive integer : offset right (centered)
    TEXT_WINDOW_X_OFFSET = 0
    # Wait for button to close? (false = wait for time)
    WAIT_FOR_BUTTON = true
      # Buttons to wait for
      # (if WAIT_FOR_BUTTON = true)
      # (Set both to the same button to check for only one)
      BUTTON_TO_WAIT_FOR1 = Input::C
      BUTTON_TO_WAIT_FOR2 = Input::B
      # Frames to wait
      # (if WAIT_FOR_BUTTON = false)
      WAIT_FOR_TIME = 120
 
#==============================================================================
# Game_System
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # Public Instance Variables (Added)
  #--------------------------------------------------------------------------
  attr_accessor :battle_pop       # holds items to popup after battle
  attr_accessor :battle_pop_gold  # holds gold to popup after battle
  #--------------------------------------------------------------------------
  # Initialize (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_gs_initialize initialize unless $@
  def initialize
    chest_pop_gs_initialize
    @battle_pop = nil
    @battle_pop_gold = 0
  end
  #--------------------------------------------------------------------------
  # Get Battle Pop (New)
  #--------------------------------------------------------------------------
  def battle_pop
    return @battle_pop
  end
  #--------------------------------------------------------------------------
  # Set Battle Pop (New)
  #--------------------------------------------------------------------------
  def battle_pop=(items)
    @battle_pop = items
  end
  #--------------------------------------------------------------------------
  # Get Battle Pop Gold (New)
  #--------------------------------------------------------------------------
  def battle_pop_gold
    return @battle_pop_gold
  end
  #--------------------------------------------------------------------------
  # Set Battle Pop Gold (New)
  #--------------------------------------------------------------------------
  def battle_pop_gold=(gold)
    @battle_pop_gold = gold
  end
end

#==============================================================================
# Game_Interpreter
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # Change Gold (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_command_125 command_125 unless $@
  def command_125
    value = operate_value(@params[0], @params[1], @params[2])
    # Pop-up
    if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[0] == 0
      $scene = Chest_Popup.new(0, value, 1)
    end
    chest_pop_command_125   
  end
  #--------------------------------------------------------------------------
  # Change Items (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_command_126 command_126 unless $@
  def command_126
    value = operate_value(@params[1], @params[2], @params[3])
    # Pop-up
    if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[1] == 0
      $scene = Chest_Popup.new(1, value, @params[0])
    end
    chest_pop_command_126
  end
  #--------------------------------------------------------------------------
  # Change Weapons (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_command_127 command_127 unless $@
  def command_127
    value = operate_value(@params[1], @params[2], @params[3])
    # Pop-up
    if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[1] == 0
      $scene = Chest_Popup.new(2, value, @params[0])
    end
    chest_pop_command_127
  end
  #--------------------------------------------------------------------------
  # Change Armor (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_command_128 command_128 unless $@
  def command_128
    value = operate_value(@params[1], @params[2], @params[3])
    # Pop-up
    if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[1] == 0
      $scene = Chest_Popup.new(3, value, @params[0])
    end
    chest_pop_command_128
  end
end

#==============================================================================
# Item Popup Window (New)
#==============================================================================

class Item_Popup_Window < Window_Base
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(0, 0, 544, 416)
    self.opacity = 0
    # Adjust X/Y to proper origin
    @x, @y = x - 27, y - 60
  end
  #--------------------------------------------------------------------------
  # Pop-Up
  #--------------------------------------------------------------------------
  def pop_up(icon_index, x_offset, y_offset)
    self.contents.clear
    # Draw pop-up icon
    draw_icon(icon_index, @x + x_offset, @y + y_offset, true)
  end
end

#==============================================================================
# Name window (New)
#==============================================================================

class Name_Window < Window_Base
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize(x, y, desc, no_desc, index, gold = false, icon = 0)
    super(x, y, 56, WLH + 32)
    # Adjust window to content's size and center
    icon_x = self.contents.text_size(index).width + 6
    width = self.contents.text_size(desc).width
    self.width = width + 32
    self.x = ((544 - self.width) / 2) + TEXT_WINDOW_X_OFFSET
    create_contents
    # Draw pop-up text
    ix = no_desc ? 0 : icon_x
    item_check = $game_system.battle_pop
    gold_check = $game_system.battle_pop_gold
    if BATTLE_POP and (item_check != nil or gold_check > 0) # If battle reward
      ix += self.contents.text_size(BATTLE_REWARD).width + 2
    end
    tx = gold ? 4 : 0
    draw_icon(icon, ix, 0) if SHOW_POPUP_TEXT_ICON and !gold
    self.contents.draw_text(tx, 0, width, WLH, desc, 0)
    draw_icon(GOLD_ICON, width - 24, 0, true) if gold
  end
end

#==============================================================================
# Scene_Base
#==============================================================================

class Scene_Base
  #--------------------------------------------------------------------------
  # Initialize (New)
  #--------------------------------------------------------------------------
  def initialize
    @disable_blur = false
  end
  #--------------------------------------------------------------------------
  # Disable blur (New)
  #--------------------------------------------------------------------------
  def disable_blur=(enabled)
    @disable_blur = enabled
  end
  #--------------------------------------------------------------------------
  # Create Snapshot for Using as Background of Another Screen (Rewrite)
  #--------------------------------------------------------------------------
  def snapshot_for_background
    $game_temp.background_bitmap.dispose
    $game_temp.background_bitmap = Graphics.snap_to_bitmap
    # Don't blur if disabled
    $game_temp.background_bitmap.blur unless @disable_blur # changed
  end
end

#==============================================================================
# Scene_Map
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # Start (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_start start unless $@
  def start
    chest_pop_start
    # Popup battle rewards
    if BATTLE_POP
      if $game_system.battle_pop_gold > 0  # gold
        gold = $game_system.battle_pop_gold
        $game_system.battle_pop_gold = 0
        $scene = Chest_Popup.new(0, gold, 0, true)
      elsif $game_system.battle_pop != nil # items
        item = $game_system.battle_pop.shift
        if item == nil
          $game_system.battle_pop = nil
        else
          type = 1 if item.is_a?(RPG::Item)
          type = 2 if item.is_a?(RPG::Weapon)
          type = 3 if item.is_a?(RPG::Armor)
          $scene = Chest_Popup.new(type, 1, item.id, true)
        end
      end
    end
  end
end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # Display Gained Experience and Gold (Rewrite)
  #--------------------------------------------------------------------------
  def display_exp_and_gold
    # Save gold to popup after battle
    $game_system.battle_pop_gold = $game_troop.gold_total if BATTLE_POP # added
    exp = $game_troop.exp_total
    gold = BATTLE_POP ? 0 : $game_troop.gold_total # changed
    $game_party.gain_gold(gold) unless BATTLE_POP  # changed
    text = sprintf(Vocab::Victory, $game_party.name)
    $game_message.texts.push('|' + text)
    if exp > 0
      text = sprintf(Vocab::ObtainExp, exp)
      $game_message.texts.push('.' + text)
    end
    if gold > 0
      text = sprintf(Vocab::ObtainGold, gold, Vocab::gold)
      $game_message.texts.push('.' + text)
    end
    wait_for_message
  end
  #--------------------------------------------------------------------------
  # Display Gained Drop Items (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_display_drop_items display_drop_items unless $@
  def display_drop_items
    # Save items to popup after battle
    $game_system.battle_pop = $game_troop.make_drop_items if BATTLE_POP
    return if BATTLE_POP
    chest_pop_display_drop_items
  end
end

#==============================================================================
# Chest_Popup (New)
#==============================================================================

class Chest_Popup < Scene_Base
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize(type, amount, index, add = false, x = nil, y = nil)
    x = $game_player.screen_x if x == nil
    y = $game_player.screen_y if y == nil
    $game_switches[POPUP_SWITCH] = !AUTO_POPUP
    $scene.disable_blur = true
    @x, @y, @amount = x, y, amount
    @gold = @no_desc = false
    case type
    when 0 # Gold
      $game_party.gain_gold(amount) if add
      @icon = GOLD_ICON
      @desc_amount = ''
      @desc = @amount.to_s
      @amount = 1
      @gold = true
    when 1 # Items
      $game_party.gain_item($data_items[index], amount) if add
      @icon = $data_items[index].icon_index
      @desc_amount = @amount.to_s + ' x'
      @desc_amount = '' if @amount == 1
      @no_desc = true if @amount == 1
      @desc = $data_items[index].name
      @amount = 1 if ONLY_SHOW_ONE
    when 2 # Weapons
      $game_party.gain_item($data_weapons[index], amount) if add
      @icon = $data_weapons[index].icon_index
      @desc_amount = @amount.to_s + ' x'
      @desc_amount = '' if @amount == 1
      @no_desc = true if @amount == 1
      @desc = $data_weapons[index].name
      @amount = 1 if ONLY_SHOW_ONE
    when 3 # Armors
      $game_party.gain_item($data_armors[index], amount) if add
      @icon = $data_armors[index].icon_index
      @desc_amount = @amount.to_s + ' x'
      @desc_amount = '' if @amount == 1
      @no_desc = true if @amount == 1
      @desc = $data_armors[index].name
      @amount = 1 if ONLY_SHOW_ONE
    end
    # Set index
    @index = @desc_amount
    # Add description to text
    if @gold
      @desc = @desc + '      '
    else
      if SHOW_POPUP_TEXT_ICON
        @desc = @desc_amount + '      ' + @desc
      else
        @desc = @desc_amount + ' ' + @desc if @desc_amount != ''
      end
    end
    # If battle reward
    item_check = $game_system.battle_pop
    gold_check = $game_system.battle_pop_gold
    if BATTLE_POP and (item_check != nil or gold_check > 0)
      @desc = BATTLE_REWARD + @desc
    end
  end
  #--------------------------------------------------------------------------
  # Start
  #--------------------------------------------------------------------------
  def start
    create_background
    # Create pop-up window
    @popup_window = Item_Popup_Window.new(@x, @y)
  end
  #--------------------------------------------------------------------------
  # Terminate
  #--------------------------------------------------------------------------
  def terminate
    # Dispose windows
    @popup_window.dispose
    @menuback_sprite.dispose
    @name_window.dispose if SHOW_POPUP_TEXT
  end
  #--------------------------------------------------------------------------
  # Return Scene
  #--------------------------------------------------------------------------
  def return_scene
    # Turn off blur and pop-up switch
    $scene.disable_blur = false
    $game_switches[POPUP_SWITCH] = false
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # Update
  #--------------------------------------------------------------------------
  def update
    super
    # Update pop-up window
    @popup_window.update
    @menuback_sprite.update
    # Do the actual popping-up
    do_popup
  end
  #--------------------------------------------------------------------------
  # Update Basic
  #--------------------------------------------------------------------------
  def update_basic
    Graphics.update             
    Input.update                 
  end
  #--------------------------------------------------------------------------
  # Wait
  #--------------------------------------------------------------------------
  def wait(duration)
    # Wait for DURATION frames
    for i in 0..duration
      update_basic
    end
  end
  #--------------------------------------------------------------------------
  # Wait for close
  #--------------------------------------------------------------------------
  def wait_for_close
    count = 0
    loop do
      update_basic
      count += 1
      # Close if button 1 pressed
      break if Input.trigger?(BUTTON_TO_WAIT_FOR1) and WAIT_FOR_BUTTON
      # Close if button 2 pressed
      break if Input.trigger?(BUTTON_TO_WAIT_FOR2) and WAIT_FOR_BUTTON
      # Close if time elapsed
      break if count >= WAIT_FOR_TIME and !WAIT_FOR_BUTTON
    end
  end
  #--------------------------------------------------------------------------
  # Create Background
  #--------------------------------------------------------------------------
  def create_background
    # Create modified background
    @menuback_sprite = Sprite.new
    @menuback_sprite.bitmap = $game_temp.background_bitmap
    @menuback_sprite.update
  end
  #--------------------------------------------------------------------------
  # Show Name
  #--------------------------------------------------------------------------
  def show_name
    x = 272
    y = TEXT_WINDOW_Y
    py = $game_player.screen_y - 32
    cy = (py - y).abs
    # Offset Y if text box is above player's position
    if cy < 128 and TEXT_WINDOW_MOVE
      y = py < y ? y + (y / 2) : y - (y / 2)
    end
    # Create Window
    @name_window = Name_Window.new(x, y, @desc, @no_desc, @index, @gold, @icon)
    # Wait for button(s) or time
    wait_for_close
    # Play sound
    Audio.se_play(C_SND, C_SND_V, C_SND_P) if WAIT_FOR_BUTTON and PLAY_C_SND
  end
  #--------------------------------------------------------------------------
  # Do Pop-Up
  #--------------------------------------------------------------------------
  def do_popup
    # Pop-up icon(s)
    for i in 1..@amount
      Audio.se_play(P_SND, P_SND_V, P_SND_P) if PLAY_P_SND
      for i in 0..4
        @popup_window.pop_up(@icon, 0, i * -4)
        @popup_window.update
        wait(2)
      end
      wait(5) if i != @amount and !ONLY_SHOW_ONE
    end
    wait(5)
    # Pop-up text
    show_name if SHOW_POPUP_TEXT
    # Exit
    return_scene
  end
end

중복이면 삭제하겠습니다..(별도 픽쳐가 필요없습니다.)

- 적용 스샷

 57ed0c9ab763ecd1f38ede86b597807f.png

출처 : http://www.rpgrevolution.com/forums/index.php?showtopic=24000

Comment '9'
  • profile
    star211 2010.12.06 17:05

    아이템상세표시인가 저런 스크립트 있는 거 봤습니다

    고로 중복. 자삭요청

  • profile
    습작 2010.12.11 02:05

    체스트 팝업2.0 올라온건 봤는데 업데이트 되었었군요... 3.0 버전은 중복 아닌것 같습니다.

  • profile
    Cloudy 2011.01.02 12:33

    적용이 안되는 경우 83번째 줄에 1이라고 적혀있는걸 0으로 바꿔주시면 되겠습니다

    그것은 자동팝업으로 제어하는 스위치를 나타내는건데 0으로 해주시면 지속적으로 자동팝업이 됩니다

     

    필요시에는 따로 스위치를 정해두셔서 스위치ID를 적어주시면 되겠습니다 ㅇㅇ;

  • ?
    박재영 2011.01.22 18:47

    안되는데요?

  • ?
    파이어 2011.01.22 23:57

    윗분말대로 안되신다면 스크립트 충돌일 확률이 높습니다.

  • ?
    초하루 2011.02.17 15:52

    좋은자료 감사합니다

  • ?
    나는바보 2011.02.28 15:43

    근데 저는 스크립트 사용하는 방법을 몰라염

  • ?
    흐느적 2011.08.09 14:50

    감사합니다-

  • ?
    빡새 2013.06.15 14:04
    잘쓸게용 ㅋ

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 3 습작 2012.12.24 5398
537 HUD KH HUD (HP MP 게이지바 스크립트) 41 아방스 2010.12.17 6421
536 전투 GTBS 1.5.1.4 - GubiD's Tactical Battle System 10 아방스 2010.12.11 4448
535 메뉴 기본메인 메뉴 아이콘 추가 10 아방스 2010.12.11 4573
534 HUD HUD 스크립트 모음 10 아방스 2010.12.11 3657
533 전투 전투후 HP/MP 퍼센테이지(지정) 회복 5 하얀슬픔 2010.12.06 2489
532 이동 및 탈것 3D 던젼 스크립트 38 아방스 2010.12.06 5772
531 장비 장비 레벨 개념 추가 스크립트 14 아방스 2010.12.06 3275
» 스킬 체스트 팝업 3.0 9 file 파이어 2010.12.05 3037
529 미니맵 MiniMap 1.0 미니맵 스크립트. 39 아방스 2010.12.02 4740
528 전투 사이드 뷰 시스템 [시트르산님 제공] 56 아방스 2010.11.29 7499
527 변수/스위치 HG_SelfVariables 셀프 변수 8 file 허걱 2010.11.19 2341
526 기타 HG_SHOOT_ANIMATION 4 file 허걱 2010.11.17 2595
525 기타 RMVX Patcher 1.2.0 by Yeyinde 5 file Alkaid 2010.11.12 2116
524 아이템 아이템 무게, 아이템별 소지수 적용 16 file 허걱 2010.11.11 2981
523 스킬 Simple Sort Skill Inventory 1.1 by cozziekuns 5 file Alkaid 2010.11.10 2350
522 스킬 Simple Sort Inventory 1.3a by cozziekuns 5 file Alkaid 2010.11.10 1636
521 전투 RPG tankentai에서의 치명적 문제점을 보완한 스크립트 2 file 톰소여동생 2010.11.03 3116
520 전투 포켓몬 스크립트 한글화 완료 26 file 서울냥이 2010.10.11 6028
519 기타 Modified Advanced Weather Script VX 1.1 3 file Alkaid 2010.10.08 1966
518 기타 책 읽기 스크립트 44 file 히류 2010.10.05 4506
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 32 Next
/ 32