查看: 2311|回复: 9

[已经解决] 这个物品获得脚本能够改变音效吗?

[复制链接]
梦石
0
星屑
80
在线时间
91 小时
注册时间
2017-2-4
回帖
15
发表于 2017-3-3 11:40:53 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 uoar 于 2017-3-3 14:21 编辑

这个脚本会在获得物品时显示介面并播放提示音效 想请问音效能够更改吗?

  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Event Window v1.01
  4. # -- Last Updated: 2011.12.27
  5. # -- Level: Easy, Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YEA-EventWindow"] = true

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2011.12.27 - Bug Fixed: Used the wrong script to hide event window.
  15. # 2011.12.26 - Started Script and Finished.
  16. #
  17. #==============================================================================
  18. # ▼ Introduction
  19. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  20. # The Event Window is a new feature added through this script that appears in
  21. # the lower left corner of the screen. Whenever the player gains or loses gold
  22. # and items, the Event Window is updated to show the changes. In addition to
  23. # showing item gains and losses, you may even add in your own text to update
  24. # through a Script Call.
  25. #
  26. #==============================================================================
  27. # ▼ Instructions
  28. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. # To install this script, open up your script editor and copy/paste this script
  30. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  31. #
  32. # -----------------------------------------------------------------------------
  33. # Script Calls - These commands are used with script calls.
  34. # -----------------------------------------------------------------------------
  35. # event_window_add_text(string)
  36. # This inserts "string" text into the Event Window. Use \n to designate
  37. # linebreaks in the string. If you wish to use text codes, write them in the
  38. # strings as \\n[2] or \\c[3] to make them work properly.
  39. #
  40. # event_window_clear_text
  41. # This causes the Event Window to clear all of the stored text. You can choose
  42. # whether or not to clear the stored Event Window text every time the player
  43. # enters a new map.
  44. #
  45. #==============================================================================
  46. # ▼ Compatibility
  47. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  48. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  49. # it will run with RPG Maker VX without adjusting.
  50. #
  51. #==============================================================================

  52. module YEA
  53.   module EVENT_WINDOW

  54.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  55.     # - Event Window Switch -
  56.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  57.     # This is the switch used for hiding the event window. When this switch is
  58.     # ON, the event window will be hidden from view. If it is OFF, the event
  59.     # window will maintain normal visibility.
  60.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  61.     HIDE_SWITCH = 24       # If switch is ON, event window will not appear.

  62.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  63.     # - General Event Window Settings -
  64.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  65.     # This section adjusts the event window. These settings adjust the overall
  66.     # appearance of the event window from the width to the number of lines
  67.     # shown and the window fade rate.
  68.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  69.     NEW_MAP_CLEAR = true    # Clear text when entering a new map?
  70.     WINDOW_WIDTH  = 280     # Event Window width.
  71.     VISIBLE_TIME  = 180     # Frames the window is visible before fading.
  72.     MAX_LINES     = 4       # Maximum number of lines shown.
  73.     WINDOW_FADE   = 8       # Fade rate for the Event Window.

  74.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  75.     # - Event Window Text Settings -
  76.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  77.     # This section adjusts the text that appears in the event window. The text
  78.     # that appears when an item is found and the text that appears when an item
  79.     # is lost will always appear before the item found. If there is more than
  80.     # one item found, the amount text will be added on after followed by the
  81.     # closing text. When gold is found, no icons will be used.
  82.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  83.     HEADER_TEXT = "\e}"                # Text that's always used at the head.
  84.     FOUND_TEXT  = "\ec[6]放入背包\ec[0] "   # Text used when an item is found.
  85.     LOST_TEXT   = "\ec[4]失去\ec[0] "    # Text used when an item is lost.
  86.     AMOUNT_TEXT = "×%s"                  # Text used to display an amount.
  87.     CLOSER_TEXT = ""                   # Text that's always used at the end.

  88.   end # EVENT_WINDOW
  89. end # YEA

  90. #==============================================================================
  91. # ▼ Editting anything past this point may potentially result in causing
  92. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  93. # halitosis so edit at your own risk.
  94. #==============================================================================

  95. #==============================================================================
  96. # ■ Switch
  97. #==============================================================================

  98. module Switch

  99.   #--------------------------------------------------------------------------
  100.   # self.hide_event_window
  101.   #--------------------------------------------------------------------------
  102.   def self.hide_event_window
  103.     return false if YEA::EVENT_WINDOW::HIDE_SWITCH <= 0
  104.     return $game_switches[YEA::EVENT_WINDOW::HIDE_SWITCH]
  105.   end

  106. end # Switch

  107. #==============================================================================
  108. # ■ Numeric
  109. #==============================================================================

  110. class Numeric

  111.   #--------------------------------------------------------------------------
  112.   # new method: group_digits
  113.   #--------------------------------------------------------------------------
  114.   unless $imported["YEA-CoreEngine"]
  115.   def group; return self.to_s; end
  116.   end # $imported["YEA-CoreEngine"]

  117. end # Numeric

  118. #==============================================================================
  119. # ■ Game_Temp
  120. #==============================================================================

  121. class Game_Temp

  122.   #--------------------------------------------------------------------------
  123.   # public instance variables
  124.   #--------------------------------------------------------------------------
  125.   attr_accessor :event_window_data

  126.   #--------------------------------------------------------------------------
  127.   # new method: add_event_window_data
  128.   #--------------------------------------------------------------------------
  129.   def add_event_window_data(text)
  130.     @event_window_data = [] if @event_window_data.nil?
  131.     return if text == ""
  132.     @event_window_data.push(text)
  133.   end

  134.   #--------------------------------------------------------------------------
  135.   # new method: clear_event_window_data
  136.   #--------------------------------------------------------------------------
  137.   def clear_event_window_data
  138.     @event_window_data = []
  139.   end

  140. end # Game_Temp

  141. #==============================================================================
  142. # ■ Game_Interpreter
  143. #==============================================================================

  144. class Game_Interpreter

  145.   #--------------------------------------------------------------------------
  146.   # alias method: command_125
  147.   #--------------------------------------------------------------------------
  148.   alias game_interpreter_command_125_ew command_125
  149.   def command_125
  150.     game_interpreter_command_125_ew
  151.     value = operate_value(@params[0], @params[1], @params[2])
  152.     $game_temp.clear_event_window_data
  153.     event_window_make_gold_text(value)
  154.   end

  155.   #--------------------------------------------------------------------------
  156.   # alias method: command_126
  157.   #--------------------------------------------------------------------------
  158.   alias game_interpreter_command_126_ew command_126
  159.   def command_126
  160.     game_interpreter_command_126_ew
  161.     value = operate_value(@params[1], @params[2], @params[3])
  162.     $game_temp.clear_event_window_data
  163.     event_window_make_item_text($data_items[@params[0]], value)
  164.   end

  165.   #--------------------------------------------------------------------------
  166.   # alias method: command_127
  167.   #--------------------------------------------------------------------------
  168.   alias game_interpreter_command_127_ew command_127
  169.   def command_127
  170.     game_interpreter_command_127_ew
  171.     value = operate_value(@params[1], @params[2], @params[3])
  172.     $game_temp.clear_event_window_data
  173.     event_window_make_item_text($data_weapons[@params[0]], value)
  174.   end

  175.   #--------------------------------------------------------------------------
  176.   # alias method: command_128
  177.   #--------------------------------------------------------------------------
  178.   alias game_interpreter_command_128_ew command_128
  179.   def command_128
  180.     game_interpreter_command_128_ew
  181.     value = operate_value(@params[1], @params[2], @params[3])
  182.     event_window_make_item_text($data_armors[@params[0]], value)
  183.   end

  184.   #--------------------------------------------------------------------------
  185.   # new method: event_window_make_gold_text
  186.   #--------------------------------------------------------------------------
  187.   def event_window_make_gold_text(value)
  188.     return unless SceneManager.scene_is?(Scene_Map)
  189.     return if Switch.hide_event_window
  190.     if value > 0
  191.       text = YEA::EVENT_WINDOW::FOUND_TEXT
  192.     elsif value < 0
  193.       text = YEA::EVENT_WINDOW::LOST_TEXT
  194.     else; return
  195.     end
  196.     text += sprintf("%s%s", value.abs.group, Vocab::currency_unit)
  197.     event_window_add_text(text)
  198.   end

  199.   #--------------------------------------------------------------------------
  200.   # new method: event_window_make_item_text
  201.   #--------------------------------------------------------------------------
  202.   def event_window_make_item_text(item, value)
  203.     return unless SceneManager.scene_is?(Scene_Map)
  204.     return if Switch.hide_event_window
  205.     if value > 0
  206.       text = YEA::EVENT_WINDOW::FOUND_TEXT
  207.     elsif value < 0
  208.       text = YEA::EVENT_WINDOW::LOST_TEXT
  209.     else; return
  210.     end
  211.     text += sprintf("\ei[%d]%s",  item.icon_index, item.name)
  212.     if value.abs > 1
  213.       fmt = YEA::EVENT_WINDOW::AMOUNT_TEXT
  214.       text += sprintf(fmt, value.abs.group)
  215.     end
  216.     event_window_add_text(text)
  217.   end

  218.   #--------------------------------------------------------------------------
  219.   # new method: event_window_add_text
  220.   #--------------------------------------------------------------------------
  221.   def event_window_add_text(text)
  222.     return unless SceneManager.scene_is?(Scene_Map)
  223.     return if Switch.hide_event_window
  224.     text = YEA::EVENT_WINDOW::HEADER_TEXT + text
  225.     text += YEA::EVENT_WINDOW::CLOSER_TEXT
  226.     SceneManager.scene.event_window_add_text(text)
  227.   end

  228.   #--------------------------------------------------------------------------
  229.   # new method: event_window_clear_text
  230.   #--------------------------------------------------------------------------
  231.   def event_window_clear_text
  232.     $game_temp.clear_event_window_data
  233.   end

  234. end # Game_Interpreter

  235. #==============================================================================
  236. # ■ Window_EventWindow
  237. #==============================================================================

  238. class Window_EventWindow < Window_Selectable

  239.   #--------------------------------------------------------------------------
  240.   # initialize
  241.   #--------------------------------------------------------------------------
  242.   def initialize
  243.     dw = YEA::EVENT_WINDOW::WINDOW_WIDTH
  244.     super(0, 0, dw, fitting_height(YEA::EVENT_WINDOW::MAX_LINES))
  245.     self.x -= 12
  246.     self.opacity = 0
  247.     self.contents_opacity = 0
  248.     @visible_counter = 0
  249.     modify_skin
  250.     deactivate
  251.   end

  252.   #--------------------------------------------------------------------------
  253.   # modify_skin
  254.   #--------------------------------------------------------------------------
  255.   def modify_skin
  256.     dup_skin = self.windowskin.dup
  257.     dup_skin.clear_rect(64,  0, 64, 64)
  258.     dup_skin.clear_rect(64, 64, 32, 32)
  259.     self.windowskin = dup_skin
  260.   end

  261.   #--------------------------------------------------------------------------
  262.   # item_max
  263.   #--------------------------------------------------------------------------
  264.   def item_max
  265.     return $game_temp.event_window_data ? $game_temp.event_window_data.size : 1
  266.   end

  267.   #--------------------------------------------------------------------------
  268.   # update
  269.   #--------------------------------------------------------------------------
  270.   def update
  271.     super
  272.     self.visible = show_window?
  273.     update_visible_counter
  274.     update_contents_opacity
  275.   end

  276.   #--------------------------------------------------------------------------
  277.   # show_window?
  278.   #--------------------------------------------------------------------------
  279.   def show_window?
  280.     return false if $game_message.visible
  281.     return true
  282.   end

  283.   #--------------------------------------------------------------------------
  284.   # update_visible_counter
  285.   #--------------------------------------------------------------------------
  286.   def update_visible_counter
  287.     return if @visible_counter <= 0
  288.     @visible_counter -= 1
  289.   end

  290.   #--------------------------------------------------------------------------
  291.   # update_contents_opacity
  292.   #--------------------------------------------------------------------------
  293.   def update_contents_opacity
  294.     return if @visible_counter > 0
  295.     return if self.contents_opacity <= 0
  296.     self.contents_opacity -= YEA::EVENT_WINDOW::WINDOW_FADE
  297.   end

  298.   #--------------------------------------------------------------------------
  299.   # instant_hide
  300.   #--------------------------------------------------------------------------
  301.   def instant_hide
  302.     @visible_counter = 0
  303.     self.contents_opacity = 0
  304.   end

  305.   #--------------------------------------------------------------------------
  306.   # add_text
  307.   #--------------------------------------------------------------------------
  308.   def add_text(text)
  309.     $game_temp.add_event_window_data(text)
  310.     refresh
  311.     self.contents_opacity = 255
  312.     @visible_counter = YEA::EVENT_WINDOW::VISIBLE_TIME
  313.     change_y_position
  314.     select(item_max - 1)
  315.   end

  316.   #--------------------------------------------------------------------------
  317.   # change_y_position  这里的数字可以改变显示条的位置,数字越小越低。
  318.   #--------------------------------------------------------------------------
  319.   def change_y_position
  320.     maximum = [item_max, YEA::EVENT_WINDOW::MAX_LINES].min
  321.     self.y = Graphics.height - fitting_height(maximum) - 180
  322.   end

  323.   #--------------------------------------------------------------------------
  324.   # refresh
  325.   #--------------------------------------------------------------------------
  326.   def refresh
  327.     create_contents
  328.     draw_all_items
  329.   end

  330.   #--------------------------------------------------------------------------
  331.   # draw_item
  332.   #--------------------------------------------------------------------------
  333.   def draw_item(index)
  334.     $game_temp.clear_event_window_data if $game_temp.event_window_data.nil?
  335.     item = $game_temp.event_window_data[index]
  336.     return if item.nil?
  337.     rect = item_rect(index)
  338.     draw_background(rect)
  339.     rect.x += 4
  340.     rect.width -= 8
  341.     draw_text_ex(rect.x, rect.y, item)
  342.   end

  343.   #--------------------------------------------------------------------------
  344.   # draw_background
  345.   #--------------------------------------------------------------------------
  346.   def draw_background(rect)
  347.     back_colour1 = Color.new(0, 0, 0, 96)
  348.     back_colour2 = Color.new(0, 0, 0, 0)
  349.     contents.gradient_fill_rect(rect, back_colour1, back_colour2)
  350.   end

  351. end # Window_EventWindow

  352. #==============================================================================
  353. # ■ Scene_Map
  354. #==============================================================================

  355. class Scene_Map < Scene_Base

  356.   #--------------------------------------------------------------------------
  357.   # alias method: create_all_windows
  358.   #--------------------------------------------------------------------------
  359.   alias scene_map_create_all_windows_event_window create_all_windows
  360.   def create_all_windows
  361.     scene_map_create_all_windows_event_window
  362.     create_event_window
  363.   end

  364.   #--------------------------------------------------------------------------
  365.   # new method: create_event_window
  366.   #--------------------------------------------------------------------------
  367.   def create_event_window
  368.     @event_window = Window_EventWindow.new
  369.   end

  370.   #--------------------------------------------------------------------------
  371.   # new method: event_window_add_text
  372.   #--------------------------------------------------------------------------
  373.   def event_window_add_text(text)
  374.     Sound.play_shop
  375.     @event_window.add_text(text)
  376.   end

  377.   #--------------------------------------------------------------------------
  378.   # alias method: post_transfer
  379.   #--------------------------------------------------------------------------
  380.   alias scene_map_post_transfer_ew post_transfer
  381.   def post_transfer
  382.     $game_temp.clear_event_window_data if YEA::EVENT_WINDOW::NEW_MAP_CLEAR
  383.     @event_window.instant_hide
  384.     scene_map_post_transfer_ew
  385.   end

  386. end # Scene_Map

  387. #==============================================================================
  388. #
  389. # ▼ End of File
  390. #
  391. #==============================================================================
复制代码

点评

428行  发表于 2017-3-3 11:57
梦石
0
星屑
80
在线时间
91 小时
注册时间
2017-2-4
回帖
15
 楼主| 发表于 2017-3-3 14:22:52 | 显示全部楼层
我把428行改做了 Sound.play_item3 后脚本出错了 请问是要怎样修改呢?

点评

成功 感谢大大  发表于 2017-3-3 19:53
RPG::SE.new('SE文件名').play  发表于 2017-3-3 14:41
我全文搜索了sound只有这一行。但我不知道va怎么放音乐,等等其他人的回答吧。  发表于 2017-3-3 14:30
回复

使用道具 举报

梦石
0
星屑
60
在线时间
52 小时
注册时间
2017-1-12
回帖
183
发表于 2017-3-3 16:13:35 | 显示全部楼层
把482行 改为RPG::SE.new('SE文件名').play
然后在\Audio\SE里放音乐 比如音乐名字叫001-System01.ogg
然后改成RPG::SE.new('001-System01.ogg').play
以下是范例

对了 把24开关 开起 可以隐藏事件窗口(关闭提示)
在65行 设置开关

物品时显示介面并播放提.rar

1.43 MB, 下载次数: 104

点评

还有什么问题也可以一起来问我的 最近好闲。。  发表于 2017-3-3 20:03
成功就好  发表于 2017-3-3 19:59
成功 感谢大大  发表于 2017-3-3 19:52
别问我是谁! 我只是一个不为人知的小白而已..
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部