设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2438|回复: 0
打印 上一主题 下一主题

[已经过期] 獲得道具時彈窗顯示腳本,請求修改

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
448 小时
注册时间
2011-10-9
帖子
184
跳转到指定楼层
1
 楼主| 发表于 2013-1-28 17:47:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 冷徹心扉 于 2013-1-28 17:50 编辑

这脚本相当优异,使用上也没有问题
但有几个地方希望能够请版上的高手们协助优化

1.战斗后获得的相同战利品能够合并计算
(如从两只史莱姆身上各掉1罐空瓶,会分两次弹窗显示为 空瓶x1、空瓶x1,希望能改为空瓶x2 藉此省去玩家的等待时间)

2.此外,有无可能在弹窗的同时,玩家依然能够移动?类似于并行处理那样
(预设是类似自动执行那样,弹窗的时候游戏为静止状态)

感激不尽
  1. #==============================================================================
  2. # Chest Item Pop-Up
  3. #==============================================================================
  4. # Author  : OriginalWij
  5. # Version : 3.1
  6. #==============================================================================
  7. # To use:
  8. #
  9. #   Normal Mode    : turn on the switch (designated below) BEFORE
  10. #                    each gold/item addition
  11. #   Automatic Mode : turn on the switch (designated below) if you DON'T want
  12. #                    popups and then turn the switch off when done
  13. #
  14. # To call manually:
  15. #
  16. #   (useful if using a break-limits script and popping-up 100+ of one item)
  17. #
  18. #   $scene = Chest_Popup.new(type, amount, index, add = false, x = pX, y = pY)
  19. #          type : 0 :gold, 1 :items, 2 :weapons, 3 :armor
  20. #        amount : number of items "gaining"
  21. #         index : item ID
  22. #           add : adds item(s) shown into inventory if true (default = false)
  23. #             x : custom X coordinate to pop-up at (default = player X)
  24. #             y : custom Y coordinate to pop-up at (default = player Y)
  25. #==============================================================================

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

  36.   #自動彈跳視窗
  37.   AUTO_POPUP = true
  38.   #彈跳窗口開關
  39.   POPUP_SWITCH = 11
  40.   # 金錢的圖示icon編號 205
  41.   GOLD_ICON = 204
  42.   # 同樣道具只出現一次彈跳視窗
  43.   ONLY_SHOW_ONE = true
  44.   # 戰鬥後戰利品的跳出視窗
  45.   BATTLE_POP = true
  46.   BATTLE_REWARD = ''#掉落道具
  47.    
  48.   # 彈出窗口時播放音效?
  49.   PLAY_P_SND = true
  50.     #######################################################
  51.     # 3 options below are valid ONLY if PLAY_P_SND = true #
  52.     #######################################################
  53.     # Sound to play upon popup
  54. #~     P_SND = 'Audio/SE/Chime2'              
  55.     P_SND = 'Audio/SE/新取得'      

  56.     P_SND_V = 75  #100  音量
  57.     P_SND_P = 100 #150  音調高低
  58.    
  59.   # 播放關閉視窗的音效?
  60.   PLAY_C_SND = true
  61.     #######################################################
  62.     # 3 options below are valid ONLY if PLAY_C_SND = true #
  63.     #######################################################
  64.     # Sound to play upon popup close
  65.     C_SND = 'Audio/SE/Cancel'
  66.     C_SND_V = 80
  67.     C_SND_P = 100
  68.    
  69.   # Show popup text?
  70.   SHOW_POPUP_TEXT = true
  71.     ##############################################################
  72.     # ALL options below are valid ONLY if SHOW_POPUP_TEXT = true #
  73.     ##############################################################
  74.     # Show icon with popup text?
  75.     SHOW_POPUP_TEXT_ICON = true #顯示彈窗圖示
  76.     # Show "gold window" (total gold) when popping-up gold?
  77.     SHOW_GOLD_WINDOW = true  #顯示總計金錢視窗
  78.     # Auto adjust window if over player
  79.     TEXT_WINDOW_MOVE = true  #自動調整窗口
  80.     # Popup text window Y coordinate
  81.     TEXT_WINDOW_Y = 195 #彈出視窗的縱標180
  82.     # Popup text window X coordinate offset
  83.     # 0 (Zero)         : 視窗中央
  84.     # negative integer : 置左offset left  (centered)
  85.     # positive integer : 置右offset right (centered)
  86.     TEXT_WINDOW_X_OFFSET = 0
  87.     # Wait for button to close? (false = wait for time)
  88. # ------------------------------------------------------------------------------------------------------------------------------------------   
  89.     WAIT_FOR_BUTTON = false #等待確認按下
  90.       # Buttons to wait for
  91.       # (if WAIT_FOR_BUTTON = true)
  92.       # (Set both to the same button to check for only one)
  93.       BUTTON_TO_WAIT_FOR1 = Input::C
  94.       BUTTON_TO_WAIT_FOR2 = Input::B
  95.       # Frames to wait
  96.       # (if WAIT_FOR_BUTTON = false)
  97.       WAIT_FOR_TIME = 25 #要等多久
  98. # ------------------------------------------------------------------------------------------------------------------------------------------         
  99.   
  100. #==============================================================================
  101. # Game_System
  102. #==============================================================================

  103. class Game_System
  104.   #--------------------------------------------------------------------------
  105.   # Public Instance Variables (Added)
  106.   #--------------------------------------------------------------------------
  107.   attr_accessor :battle_pop       # holds items to popup after battle
  108.   attr_accessor :battle_pop_gold  #
  109.   #--------------------------------------------------------------------------
  110.   # Initialize (Mod)
  111.   #--------------------------------------------------------------------------
  112.   alias chest_pop_gs_initialize initialize unless $@
  113.   def initialize
  114.     chest_pop_gs_initialize
  115.     @battle_pop = nil
  116.     @battle_pop_gold = 0
  117.   end
  118. end

  119. #==============================================================================
  120. # Game_Interpreter
  121. #==============================================================================

  122. class Game_Interpreter
  123.   #--------------------------------------------------------------------------
  124.   # Change Gold (Mod)
  125.   #--------------------------------------------------------------------------
  126.   alias chest_pop_command_125 command_125 unless $@
  127.   def command_125
  128.     value = operate_value(@params[0], @params[1], @params[2])
  129.     # Pop-up
  130.     if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[0] == 0
  131.       $scene = Chest_Popup.new(0, value, 1)
  132.     end
  133.     chest_pop_command_125   
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # Change Items (Mod)
  137.   #--------------------------------------------------------------------------
  138.   alias chest_pop_command_126 command_126 unless $@
  139.   def command_126
  140.     value = operate_value(@params[1], @params[2], @params[3])
  141.     # Pop-up
  142.     if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[1] == 0
  143.       $scene = Chest_Popup.new(1, value, @params[0])
  144.     end
  145.     chest_pop_command_126
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # Change Weapons (Mod)
  149.   #--------------------------------------------------------------------------
  150.   alias chest_pop_command_127 command_127 unless $@
  151.   def command_127
  152.     value = operate_value(@params[1], @params[2], @params[3])
  153.     # Pop-up
  154.     if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[1] == 0
  155.       $scene = Chest_Popup.new(2, value, @params[0])
  156.     end
  157.     chest_pop_command_127
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # Change Armor (Mod)
  161.   #--------------------------------------------------------------------------
  162.   alias chest_pop_command_128 command_128 unless $@
  163.   def command_128
  164.     value = operate_value(@params[1], @params[2], @params[3])
  165.     # Pop-up
  166.     if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[1] == 0
  167.       $scene = Chest_Popup.new(3, value, @params[0])
  168.     end
  169.     chest_pop_command_128
  170.   end
  171. end

  172. #==============================================================================
  173. # Item Popup Window (New)
  174. #==============================================================================

  175. class Item_Popup_Window < Window_Base
  176.   #--------------------------------------------------------------------------
  177.   # Initialize
  178.   #--------------------------------------------------------------------------
  179.   def initialize(x, y)
  180.     super(0, 0, Graphics.width, Graphics.height) # res
  181.     self.opacity = 0
  182.     # Adjust X/Y to proper origin
  183.     @x, @y = x - 27, y - 60
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # Pop-Up
  187.   #--------------------------------------------------------------------------
  188.   def pop_up(icon_index, x_offset, y_offset)
  189.     self.contents.clear
  190.     # Draw pop-up icon
  191.     draw_icon(icon_index, @x + x_offset, @y + y_offset, true)
  192.   end
  193. end

  194. #==============================================================================
  195. # Name window (New)
  196. #==============================================================================

  197. class Name_Window < Window_Base
  198.   #--------------------------------------------------------------------------
  199.   # Initialize
  200.   #--------------------------------------------------------------------------
  201.   def initialize(x, y, desc, no_desc, index, gold = false, icon = 0)
  202.     super(x, y, 56, WLH + 32-2)   
  203.     # Adjust window to content's size and center
  204.     icon_x = self.contents.text_size(index).width + 6-4 #
  205.     width = self.contents.text_size(desc).width
  206.     self.width = width + 30#32
  207.     self.x = ((Graphics.width - self.width) / 2) + TEXT_WINDOW_X_OFFSET # res
  208.     create_contents
  209.     # Draw pop-up text
  210.     ix = no_desc ? 0 : icon_x
  211.     item_check = $game_system.battle_pop
  212.     gold_check = $game_system.battle_pop_gold
  213.     if BATTLE_POP and (item_check != nil or gold_check > 0) # If battle reward
  214.       ix += self.contents.text_size(BATTLE_REWARD).width + 2
  215.     end
  216.     tx = gold ? 4 : 0
  217.     draw_icon(icon, ix-1, 0-1) if SHOW_POPUP_TEXT_ICON and !gold #
  218.     self.contents.draw_text(tx-6, 0-1, width, WLH, desc, 0) #
  219.     draw_icon(GOLD_ICON, width - 24, 0, true) if gold
  220.   end
  221. end

  222. #==============================================================================
  223. # Scene_Base
  224. #==============================================================================

  225. class Scene_Base
  226.   #--------------------------------------------------------------------------
  227.   # Initialize (New)
  228.   #--------------------------------------------------------------------------
  229.   def initialize
  230.     @disable_blur = false
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # Disable blur (New)
  234.   #--------------------------------------------------------------------------
  235.   def disable_blur=(enabled)
  236.     @disable_blur = enabled
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # Create Snapshot for Using as Background of Another Screen (Rewrite)
  240.   #--------------------------------------------------------------------------
  241.   def snapshot_for_background
  242.     $game_temp.background_bitmap.dispose
  243.     $game_temp.background_bitmap = Graphics.snap_to_bitmap
  244.     # Don't blur if disabled
  245.     $game_temp.background_bitmap.blur unless @disable_blur # changed
  246.   end
  247. end

  248. #==============================================================================
  249. # Scene_Map
  250. #==============================================================================

  251. class Scene_Map < Scene_Base
  252.   #--------------------------------------------------------------------------
  253.   # Start (Mod)
  254.   #--------------------------------------------------------------------------
  255.   alias chest_pop_start start unless $@
  256.   def start
  257.     chest_pop_start
  258.     # Popup battle rewards
  259.     if BATTLE_POP
  260.       if $game_system.battle_pop_gold > 0  # gold
  261.         gold = $game_system.battle_pop_gold
  262.         $game_system.battle_pop_gold = 0
  263.         $scene = Chest_Popup.new(0, gold, 0, true)
  264.       elsif $game_system.battle_pop != nil # items
  265.         item = $game_system.battle_pop.shift
  266.         if item == nil
  267.           $game_system.battle_pop = nil
  268.         else
  269.           type = 1 if item.is_a?(RPG::Item)
  270.           type = 2 if item.is_a?(RPG::Weapon)
  271.           type = 3 if item.is_a?(RPG::Armor)
  272.           $scene = Chest_Popup.new(type, 1, item.id, true)
  273.         end
  274.       end
  275.     end
  276.   end
  277. end

  278. #==============================================================================
  279. # Scene_Battle
  280. #==============================================================================

  281. class Scene_Battle < Scene_Base
  282.   #--------------------------------------------------------------------------
  283.   # Display Gained Experience and Gold (Rewrite)
  284.   #--------------------------------------------------------------------------
  285.   def display_exp_and_gold
  286.     # Save gold to popup after battle
  287.     $game_system.battle_pop_gold = $game_troop.gold_total if BATTLE_POP # added
  288.     exp = $game_troop.exp_total
  289.     gold = BATTLE_POP ? 0 : $game_troop.gold_total # changed
  290.     $game_party.gain_gold(gold) unless BATTLE_POP  # changed
  291.     text = sprintf(Vocab::Victory, $game_party.name)
  292.     $game_message.texts.push('\|' + text)
  293.     if exp > 0
  294.       text = sprintf(Vocab::ObtainExp, exp)
  295.       $game_message.texts.push('\.' + text)
  296.     end
  297.     if gold > 0
  298.       text = sprintf(Vocab::ObtainGold, gold, Vocab::gold)
  299.       $game_message.texts.push('\.' + text)
  300.     end
  301.     wait_for_message
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # Display Gained Drop Items (Mod)
  305.   #--------------------------------------------------------------------------
  306.   alias chest_pop_display_drop_items display_drop_items unless $@
  307.   def display_drop_items
  308.     # Save items to popup after battle
  309.     $game_system.battle_pop = $game_troop.make_drop_items if BATTLE_POP
  310.     return if BATTLE_POP
  311.     chest_pop_display_drop_items
  312.   end
  313. end

  314. #==============================================================================
  315. # Chest_Popup (New)
  316. #==============================================================================

  317. class Chest_Popup < Scene_Base
  318.   #--------------------------------------------------------------------------
  319.   # Initialize
  320.   #--------------------------------------------------------------------------
  321.   def initialize(type, amount, index, add = false, x = nil, y = nil)
  322.     x = $game_player.screen_x if x == nil
  323.     y = $game_player.screen_y if y == nil
  324.     $game_switches[POPUP_SWITCH] = !AUTO_POPUP
  325.     $scene.disable_blur = true
  326.     @x, @y, @amount = x, y, amount
  327.     [url=home.php?mod=space&uid=236945]@gold[/url] = @no_desc = false#
  328.     case type
  329.     when 0 # 金錢old
  330.       $game_party.gain_gold(amount) if add
  331.       @icon = GOLD_ICON
  332.       @desc_amount = ''
  333.       @desc = @amount.to_s #+ ''  #
  334.       @amount = 1
  335.       [url=home.php?mod=space&uid=236945]@gold[/url] = false #
  336.       
  337.     when 1 # 道具
  338.       $game_party.gain_item($data_items[index], amount) if add
  339.       @icon = $data_items[index].icon_index
  340.                                                    #
  341. #~       @desc_amount = '取得' + @amount.to_s + '個'  #
  342.       @desc_amount = ''  #      
  343.       @desc_amount = '' if @amount == 1
  344.       @no_desc = true if @amount == 1
  345.       #取得道具名稱欄位
  346.       @desc = $data_items[index].name + ' x ' + @amount.to_s + '' #
  347.       @amount = 1 if ONLY_SHOW_ONE
  348.       
  349.     when 2 # 武器
  350.       $game_party.gain_item($data_weapons[index], amount) if add
  351.       @icon = $data_weapons[index].icon_index
  352.       @desc_amount = ''
  353.       @desc_amount = '' if @amount == 1
  354.       @no_desc = true if @amount == 1
  355.       @desc = $data_weapons[index].name + ' x ' + @amount.to_s + ''
  356.       @amount = 1 if ONLY_SHOW_ONE
  357.       
  358.     when 3 # 護具
  359.       $game_party.gain_item($data_armors[index], amount) if add
  360.       @icon = $data_armors[index].icon_index
  361.       @desc_amount = ''
  362.       @desc_amount = '' if @amount == 1
  363.       @no_desc = true if @amount == 1
  364.       @desc = $data_armors[index].name + ' x ' + @amount.to_s + ''
  365.       @amount = 1 if ONLY_SHOW_ONE
  366.     end
  367.     # Set index
  368.     @index = @desc_amount
  369.     # 添加描述文本
  370.     if @gold
  371.       @desc = @desc + ''#金幣和名稱的距離
  372.     else
  373.       if SHOW_POPUP_TEXT_ICON
  374.         @desc = @desc_amount + '      ' + @desc #
  375.       else
  376.         @desc = @desc_amount + '' + @desc if @desc_amount != ''
  377.       end
  378.     end
  379.     # If 戰鬥獎勵
  380.     item_check = $game_system.battle_pop
  381.     gold_check = $game_system.battle_pop_gold
  382.     if BATTLE_POP and (item_check != nil or gold_check > 0)
  383.       @desc = BATTLE_REWARD + @desc
  384.     end

  385.    
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # Start
  389.   #--------------------------------------------------------------------------
  390.   def start
  391.     create_background
  392.     # Create pop-up window
  393.     @popup_window = Item_Popup_Window.new(@x, @y)
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # Terminate
  397.   #--------------------------------------------------------------------------
  398.   def terminate
  399.     # Dispose windows
  400.     @popup_window.dispose
  401.     @menuback_sprite.dispose
  402.     @name_window.dispose if SHOW_POPUP_TEXT
  403.   end
  404.   #--------------------------------------------------------------------------
  405.   # Return Scene
  406.   #--------------------------------------------------------------------------
  407.   def return_scene
  408.     # Turn off blur and pop-up switch
  409.     $scene.disable_blur = false
  410.     $game_switches[POPUP_SWITCH] = false
  411.     $scene = Scene_Map.new
  412.   end
  413.   #--------------------------------------------------------------------------
  414.   # Update
  415.   #--------------------------------------------------------------------------
  416.   def update
  417.     super
  418.     # Update pop-up window
  419.     @popup_window.update
  420.     @menuback_sprite.update
  421.     # Do the actual popping-up
  422.     do_popup
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # Update Basic
  426.   #--------------------------------------------------------------------------
  427.   def update_basic
  428.     Graphics.update              
  429.     Input.update                  
  430.   end
  431.   #--------------------------------------------------------------------------
  432.   # Wait
  433.   #--------------------------------------------------------------------------
  434.   def wait(duration)
  435.     # Wait for DURATION frames
  436.     for i in 0..duration
  437.       update_basic
  438.     end
  439.   end
  440.   #--------------------------------------------------------------------------
  441.   # Wait for close
  442.   #--------------------------------------------------------------------------
  443.   def wait_for_close
  444.     count = 0
  445.     loop do
  446.       update_basic
  447.       count += 1
  448.       # Close if button 1 pressed
  449.       break if Input.trigger?(BUTTON_TO_WAIT_FOR1) and WAIT_FOR_BUTTON
  450.       # Close if button 2 pressed
  451.       break if Input.trigger?(BUTTON_TO_WAIT_FOR2) and WAIT_FOR_BUTTON
  452.       # Close if time elapsed
  453.       break if count >= WAIT_FOR_TIME and !WAIT_FOR_BUTTON
  454.     end
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # Create Background
  458.   #--------------------------------------------------------------------------
  459.   def create_background
  460.     # Create modified background
  461.     @menuback_sprite = Sprite.new
  462.     @menuback_sprite.bitmap = $game_temp.background_bitmap
  463.     @menuback_sprite.update
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # Show Name
  467.   #--------------------------------------------------------------------------
  468.   def show_name
  469.     x = Graphics.width / 2 # res
  470.     y = TEXT_WINDOW_Y
  471.     py = $game_player.screen_y - 32
  472.     cy = (py - y).abs
  473.     # Offset Y if text box is above player's position
  474.     if cy < 128 and TEXT_WINDOW_MOVE
  475.       y = py < y ? y + (y / 2) : y - (y / 2)
  476.     end
  477.     # Create Window (and gold window)
  478.     @name_window = Name_Window.new(x, y, @desc, @no_desc, @index, @gold, @icon)
  479.     if SHOW_GOLD_WINDOW and @gold
  480.       @gold_window = Window_Gold.new(Graphics.width - 160, 0)
  481.     end
  482.     # Wait for button(s) or time
  483.     wait_for_close
  484.     # Close gold window
  485.     @gold_window.dispose if SHOW_GOLD_WINDOW and @gold
  486.     # Play sound
  487.     Audio.se_play(C_SND, C_SND_V, C_SND_P) if WAIT_FOR_BUTTON and PLAY_C_SND
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # Do Pop-Up
  491.   #--------------------------------------------------------------------------
  492.   def do_popup
  493.     # Pop-up icon(s)
  494.     for i in 1..@amount
  495.       Audio.se_play(P_SND, P_SND_V, P_SND_P) if PLAY_P_SND
  496.       for i in 0..4
  497.         @popup_window.pop_up(@icon, 0, i * -4) #
  498.         @popup_window.update
  499.         wait(0)
  500.       end
  501.       wait(0) if i != @amount and !ONLY_SHOW_ONE
  502.     end
  503.     wait(0)
  504.     # Pop-up text
  505.     show_name if SHOW_POPUP_TEXT
  506.     # Exit
  507.     return_scene
  508.   end
  509. end
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-12-23 02:06

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表