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

Project1

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

[已经解决] 如何解决用$game_party.gain_item获得物品时得失物品提示失效

[复制链接]

Lv2.观梦者

梦石
0
星屑
882
在线时间
83 小时
注册时间
2022-9-13
帖子
14
跳转到指定楼层
1
发表于 2022-9-21 08:53:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
如题,在下找遍了所有会用的物品得失提示脚本,都不能提示通过gain_item得到的物品
通过搜索找到了一个已解决的帖子,说是通过仿写command_126就可以解决这个问题,原贴脚本如下
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2. # ● 得失物品提示
  3. #--------------------------------------------------------------------------
  4.  
  5. module Taroxd end
  6.  
  7. module Taroxd::GainMessage
  8.  
  9.   # --- 设置 ---
  10.  
  11.   # 信息格式
  12.  
  13.   # 转义符:
  14.   # \name    代表物品名称 / 金钱单位
  15.   # \value   代表获得 / 失去的物品 / 金钱数量
  16.   # \icon    绘制物品 / 金钱的图标
  17.   # \action  代表“获得”或者“失去”。可在下面修改。
  18.   # 支持“显示文字”中的所有转义符。
  19.   ITEM_FORMAT  = '\action了 \name * \value'
  20.   GOLD_FORMAT  = '\action了 \value \name'
  21.   ACTION_GAIN  = '获得'
  22.   ACTION_LOSE  = '失去'
  23.   GOLD_ICON_INDEX = 361           # 金钱图标的索引
  24.  
  25.   BACKGROUND   = 1                # 窗口背景(0/1/2)
  26.   POSITION     = 1                # 显示位置(0/1/2)
  27.  
  28.   # 音效(不需要的话可以直接删去对应的行)
  29.   GAIN_GOLD_SE = 'Shop'           # 获得金钱
  30.   LOSE_GOLD_SE = 'Blow2'          # 失去金钱
  31.   GAIN_ITEM_SE = 'Item1'          # 获得物品
  32.   LOSE_ITEM_SE = LOSE_GOLD_SE     # 失去物品
  33.  
  34.   # 设置功能是否启用。
  35.   # true:启用。
  36.   # false:不启用。
  37.   # $game_switches[开关ID]: 对应开关打开时。
  38.   def self.enabled?
  39.     true
  40.   end
  41.  
  42.   # --- 设置结束 ---
  43.  
  44.   # 显示提示信息。获得金钱时将 item 设为 nil。
  45.   def self.show(value, item)
  46.     @item = item
  47.     @value = value
  48.     $game_message.background = BACKGROUND
  49.     $game_message.position = POSITION
  50.     $game_message.add(message)
  51.     play_se
  52.   end
  53.  
  54.   private
  55.  
  56.   # 获取提示的消息
  57.   def self.message
  58.     if @item
  59.       format = ITEM_FORMAT
  60.       icon_index = @item.icon_index
  61.       name = @item.name
  62.     else
  63.       format = GOLD_FORMAT
  64.       icon_index = GOLD_ICON_INDEX
  65.       name = Vocab.currency_unit
  66.     end
  67.  
  68.     # gsub: 以替换前的字符串为键,替换后内容为值的 hash。可以自由设置。
  69.     gsub = {
  70.       '\action' => @value > 0 ? ACTION_GAIN : ACTION_LOSE,
  71.       '\value'  => @value.abs,
  72.       '\icon'   => "\\I[#{icon_index}]",
  73.       '\name'   => name
  74.     }
  75.  
  76.     format.gsub(Regexp.union(gsub.keys), gsub)
  77.   end
  78.  
  79.   def self.play_se
  80.     const = :"#{@value > 0 ? 'GAIN' : 'LOSE'}_#{@item ? 'ITEM' : 'GOLD'}_SE"
  81.     se = const_defined?(const) && const_get(const)
  82.     Audio.se_play('Audio/SE/' + se) if se
  83.   end
  84. end
  85.  
  86. class Game_Party < Game_Unit
  87.   # 获取道具总数(包括装备)
  88.   def item_number_with_equip(item)
  89.     members.inject(item_number(item)) { |a, e| a + e.equips.count(item) }
  90.   end
  91. end
  92.  
  93. class Game_Interpreter
  94.  
  95.   GainMessage = Taroxd::GainMessage
  96.  
  97.   # 别名:不显示提示窗口的事件指令
  98.   alias_method :gain_gold_without_message,   :command_125
  99.   alias_method :gain_item_without_message,   :command_126
  100.   alias_method :gain_weapon_without_message, :command_127
  101.   alias_method :gain_armor_without_message,  :command_128
  102.  
  103.   # 显示提示窗口
  104.   def show_gain_message(value, item = nil)
  105.     return if value.zero?
  106.     GainMessage.show(value, item)
  107.     wait_for_message
  108.   end
  109.  
  110.   # 增减持有金钱
  111.   def command_125
  112.     return gain_gold_without_message unless GainMessage.enabled?
  113.     last_gold = $game_party.gold
  114.     gain_gold_without_message
  115.     show_gain_message($game_party.gold - last_gold)
  116.   end
  117.  
  118.   # 增减物品
  119.   def command_126
  120.     return gain_item_without_message unless GainMessage.enabled?
  121.     item = $data_items[@params[0]]
  122.     last_num = $game_party.item_number(item)
  123.     gain_item_without_message
  124.     show_gain_message($game_party.item_number(item) - last_num, item)
  125.   end
  126.  
  127.   # 增减武器
  128.   def command_127
  129.     return gain_weapon_without_message unless GainMessage.enabled?
  130.     item = $data_weapons[@params[0]]
  131.     last_num = $game_party.item_number_with_equip(item)
  132.     gain_weapon_without_message
  133.     value = $game_party.item_number_with_equip(item) - last_num
  134.     show_gain_message(value, item)
  135.   end
  136.  
  137.   # 增减护甲
  138.   def command_128
  139.     return gain_armor_without_message unless GainMessage.enabled?
  140.     item = $data_armors[@params[0]]
  141.     last_num = $game_party.item_number_with_equip(item)
  142.     gain_armor_without_message
  143.     value = $game_party.item_number_with_equip(item) - last_num
  144.     show_gain_message(value, item)
  145.   end
  146. end


但在下是个刚接触RM的小白,脚本啥的完全不会写
原贴又是15年的,那么久的贴实在不好意思挖坟……
所以就自己发了个帖子请教各方的大佬们。
萌新也没啥拿得出手的东西,还请大佬们不吝赐教


这边再贴另外一个物品得失的脚本,感觉视觉效果上会比上面的这个好一些(?)
不过这个脚本据说会有大量获得只显示最后一个的问题,在下还没有这样使用所以不太清楚。
RUBY 代码复制
  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.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-EventWindow"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2011.12.27 - Bug Fixed: Used the wrong script to hide event window.
  17. # 2011.12.26 - Started Script and Finished.
  18. #
  19. #==============================================================================
  20. # ▼ Introduction
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # The Event Window is a new feature added through this script that appears in
  23. # the lower left corner of the screen. Whenever the player gains or loses gold
  24. # and items, the Event Window is updated to show the changes. In addition to
  25. # showing item gains and losses, you may even add in your own text to update
  26. # through a Script Call.
  27. #
  28. #==============================================================================
  29. # ▼ Instructions
  30. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  31. # To install this script, open up your script editor and copy/paste this script
  32. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  33. #
  34. # -----------------------------------------------------------------------------
  35. # Script Calls - These commands are used with script calls.
  36. # -----------------------------------------------------------------------------
  37. # event_window_add_text(string)
  38. # This inserts "string" text into the Event Window. Use \n to designate
  39. # linebreaks in the string. If you wish to use text codes, write them in the
  40. # strings as \\n[2] or \\c[3] to make them work properly.
  41. #
  42. # event_window_clear_text
  43. # This causes the Event Window to clear all of the stored text. You can choose
  44. # whether or not to clear the stored Event Window text every time the player
  45. # enters a new map.
  46. #
  47. #==============================================================================
  48. # ▼ Compatibility
  49. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  50. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  51. # it will run with RPG Maker VX without adjusting.
  52. #
  53. #==============================================================================
  54.  
  55. module YEA
  56.   module EVENT_WINDOW
  57.  
  58.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  59.     # - Event Window Switch -
  60.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  61.     # This is the switch used for hiding the event window. When this switch is
  62.     # ON, the event window will be hidden from view. If it is OFF, the event
  63.     # window will maintain normal visibility.
  64.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  65.     HIDE_SWITCH = 24       # 如果开关打开,不会出现事件窗口。
  66.  
  67.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  68.     # - General Event Window Settings -
  69.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  70.     # This section adjusts the event window. These settings adjust the overall
  71.     # appearance of the event window from the width to the number of lines
  72.     # shown and the window fade rate.
  73.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  74.     NEW_MAP_CLEAR = true    # Clear text when entering a new map?
  75.     WINDOW_WIDTH  = 480     # 事件窗口的宽度.
  76.     VISIBLE_TIME  = 180     # 帧窗口是褪色之前可见。
  77.     MAX_LINES     = 8       # 最大行数显示。
  78.     WINDOW_FADE   = 8       # 褪色率的事件窗口。
  79.  
  80.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  81.     # - Event Window Text Settings -
  82.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  83.     # This section adjusts the text that appears in the event window. The text
  84.     # that appears when an item is found and the text that appears when an item
  85.     # is lost will always appear before the item found. If there is more than
  86.     # one item found, the amount text will be added on after followed by the
  87.     # closing text. When gold is found, no icons will be used.
  88.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  89.     HEADER_TEXT = ""                # Text that's always used at the head.
  90.     FOUND_TEXT  = "\ec[6]获得\ec[0] "   # Text used when an item is found.
  91.     LOST_TEXT   = "\ec[4]失去\ec[0] "    # Text used when an item is lost.
  92.     AMOUNT_TEXT = "×%s"                  # Text used to display an amount.
  93.     CLOSER_TEXT = ""                   # Text that's always used at the end.
  94.  
  95.   end # EVENT_WINDOW
  96. end # YEA
  97.  
  98. #==============================================================================
  99. # ▼ Editting anything past this point may potentially result in causing
  100. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  101. # halitosis so edit at your own risk.
  102. #==============================================================================
  103.  
  104. #==============================================================================
  105. # ■ Switch
  106. #==============================================================================
  107.  
  108. module Switch
  109.  
  110.   #--------------------------------------------------------------------------
  111.   # self.hide_event_window
  112.   #--------------------------------------------------------------------------
  113.   def self.hide_event_window
  114.     return false if YEA::EVENT_WINDOW::HIDE_SWITCH <= 0
  115.     return $game_switches[YEA::EVENT_WINDOW::HIDE_SWITCH]
  116.   end
  117.  
  118. end # Switch
  119.  
  120. #==============================================================================
  121. # ■ Numeric
  122. #==============================================================================
  123.  
  124. class Numeric
  125.  
  126.   #--------------------------------------------------------------------------
  127.   # new method: group_digits
  128.   #--------------------------------------------------------------------------
  129.   unless $imported["YEA-CoreEngine"]
  130.   def group; return self.to_s; end
  131.   end # $imported["YEA-CoreEngine"]
  132.  
  133. end # Numeric
  134.  
  135. #==============================================================================
  136. # ■ Game_Temp
  137. #==============================================================================
  138.  
  139. class Game_Temp
  140.  
  141.   #--------------------------------------------------------------------------
  142.   # public instance variables
  143.   #--------------------------------------------------------------------------
  144.   attr_accessor :event_window_data
  145.  
  146.   #--------------------------------------------------------------------------
  147.   # new method: add_event_window_data
  148.   #--------------------------------------------------------------------------
  149.   def add_event_window_data(text)
  150.     @event_window_data = [] if @event_window_data.nil?
  151.     return if text == ""
  152.     @event_window_data.push(text)
  153.   end
  154.  
  155.   #--------------------------------------------------------------------------
  156.   # new method: clear_event_window_data
  157.   #--------------------------------------------------------------------------
  158.   def clear_event_window_data
  159.     @event_window_data = []
  160.   end
  161.  
  162. end # Game_Temp
  163.  
  164. #==============================================================================
  165. # ■ Game_Interpreter
  166. #==============================================================================
  167.  
  168. class Game_Interpreter
  169.  
  170.   #--------------------------------------------------------------------------
  171.   # alias method: command_125
  172.   #--------------------------------------------------------------------------
  173.   alias game_interpreter_command_125_ew command_125
  174.   def command_125
  175.     game_interpreter_command_125_ew
  176.     value = operate_value(@params[0], @params[1], @params[2])
  177.     $game_temp.clear_event_window_data
  178.     event_window_make_gold_text(value)
  179.   end
  180.  
  181.   #--------------------------------------------------------------------------
  182.   # alias method: command_126
  183.   #--------------------------------------------------------------------------
  184.   alias game_interpreter_command_126_ew command_126
  185.   def command_126
  186.     game_interpreter_command_126_ew
  187.     value = operate_value(@params[1], @params[2], @params[3])
  188.     $game_temp.clear_event_window_data
  189.     event_window_make_item_text($data_items[@params[0]], value)
  190.   end
  191.  
  192.   #--------------------------------------------------------------------------
  193.   # alias method: command_127
  194.   #--------------------------------------------------------------------------
  195.   alias game_interpreter_command_127_ew command_127
  196.   def command_127
  197.     game_interpreter_command_127_ew
  198.     value = operate_value(@params[1], @params[2], @params[3])
  199.     $game_temp.clear_event_window_data
  200.     event_window_make_item_text($data_weapons[@params[0]], value)
  201.   end
  202.  
  203.   #--------------------------------------------------------------------------
  204.   # alias method: command_128
  205.   #--------------------------------------------------------------------------
  206.   alias game_interpreter_command_128_ew command_128
  207.   def command_128
  208.     game_interpreter_command_128_ew
  209.     value = operate_value(@params[1], @params[2], @params[3])
  210.     event_window_make_item_text($data_armors[@params[0]], value)
  211.   end
  212.  
  213.   #--------------------------------------------------------------------------
  214.   # new method: event_window_make_gold_text
  215.   #--------------------------------------------------------------------------
  216.   def event_window_make_gold_text(value)
  217.     return unless SceneManager.scene_is?(Scene_Map)
  218.     return if Switch.hide_event_window
  219.     if value > 0
  220.       text = YEA::EVENT_WINDOW::FOUND_TEXT
  221.     elsif value < 0
  222.       text = YEA::EVENT_WINDOW::LOST_TEXT
  223.     else; return
  224.     end
  225.     text += sprintf("%s%s", value.abs.group, Vocab::currency_unit)
  226.     event_window_add_text(text)
  227.   end
  228.  
  229.   #--------------------------------------------------------------------------
  230.   # new method: event_window_make_item_text
  231.   #--------------------------------------------------------------------------
  232.   def event_window_make_item_text(item, value)
  233.     return unless SceneManager.scene_is?(Scene_Map)
  234.     return if Switch.hide_event_window
  235.     if value > 0
  236.       text = YEA::EVENT_WINDOW::FOUND_TEXT
  237.     elsif value < 0
  238.       text = YEA::EVENT_WINDOW::LOST_TEXT
  239.     else; return
  240.     end
  241.     text += sprintf("\ei[%d]%s", item.icon_index, item.name)
  242.     if value.abs > 1
  243.       fmt = YEA::EVENT_WINDOW::AMOUNT_TEXT
  244.       text += sprintf(fmt, value.abs.group)
  245.     end
  246.     event_window_add_text(text)
  247.   end
  248.  
  249.   #--------------------------------------------------------------------------
  250.   # new method: event_window_add_text
  251.   #--------------------------------------------------------------------------
  252.   def event_window_add_text(text)
  253.     return unless SceneManager.scene_is?(Scene_Map)
  254.     return if Switch.hide_event_window
  255.     text = YEA::EVENT_WINDOW::HEADER_TEXT + text
  256.     text += YEA::EVENT_WINDOW::CLOSER_TEXT
  257.     SceneManager.scene.event_window_add_text(text)
  258.   end
  259.  
  260.   #--------------------------------------------------------------------------
  261.   # new method: event_window_clear_text
  262.   #--------------------------------------------------------------------------
  263.   def event_window_clear_text
  264.     $game_temp.clear_event_window_data
  265.   end
  266.  
  267. end # Game_Interpreter
  268.  
  269. #==============================================================================
  270. # ■ Window_EventWindow
  271. #==============================================================================
  272.  
  273. class Window_EventWindow < Window_Selectable
  274.  
  275.   #--------------------------------------------------------------------------
  276.   # initialize
  277.   #--------------------------------------------------------------------------
  278.   def initialize
  279.     dw = YEA::EVENT_WINDOW::WINDOW_WIDTH
  280.     super(0, 0, dw, fitting_height(YEA::EVENT_WINDOW::MAX_LINES))
  281.     self.x -= 12
  282.     self.opacity = 0
  283.     self.contents_opacity = 0
  284.     @visible_counter = 0
  285.     modify_skin
  286.     deactivate
  287.   end
  288.  
  289.   #--------------------------------------------------------------------------
  290.   # modify_skin
  291.   #--------------------------------------------------------------------------
  292.   def modify_skin
  293.     dup_skin = self.windowskin.dup
  294.     dup_skin.clear_rect(64,  0, 64, 64)
  295.     dup_skin.clear_rect(64, 64, 32, 32)
  296.     self.windowskin = dup_skin
  297.   end
  298.  
  299.   #--------------------------------------------------------------------------
  300.   # item_max
  301.   #--------------------------------------------------------------------------
  302.   def item_max
  303.     return $game_temp.event_window_data ? $game_temp.event_window_data.size : 1
  304.   end
  305.  
  306.   #--------------------------------------------------------------------------
  307.   # update
  308.   #--------------------------------------------------------------------------
  309.   def update
  310.     super
  311.     self.visible = show_window?
  312.     update_visible_counter
  313.     update_contents_opacity
  314.   end
  315.  
  316.   #--------------------------------------------------------------------------
  317.   # show_window?
  318.   #--------------------------------------------------------------------------
  319.   def show_window?
  320.     return false if $game_message.visible
  321.     return true
  322.   end
  323.  
  324.   #--------------------------------------------------------------------------
  325.   # update_visible_counter
  326.   #--------------------------------------------------------------------------
  327.   def update_visible_counter
  328.     return if @visible_counter <= 0
  329.     @visible_counter -= 1
  330.   end
  331.  
  332.   #--------------------------------------------------------------------------
  333.   # update_contents_opacity
  334.   #--------------------------------------------------------------------------
  335.   def update_contents_opacity
  336.     return if @visible_counter > 0
  337.     return if self.contents_opacity <= 0
  338.     self.contents_opacity -= YEA::EVENT_WINDOW::WINDOW_FADE
  339.   end
  340.  
  341.   #--------------------------------------------------------------------------
  342.   # instant_hide
  343.   #--------------------------------------------------------------------------
  344.   def instant_hide
  345.     @visible_counter = 0
  346.     self.contents_opacity = 0
  347.   end
  348.  
  349.   #--------------------------------------------------------------------------
  350.   # add_text
  351.   #--------------------------------------------------------------------------
  352.   def add_text(text)
  353.     $game_temp.add_event_window_data(text)
  354.     refresh
  355.     self.contents_opacity = 255
  356.     @visible_counter = YEA::EVENT_WINDOW::VISIBLE_TIME
  357.     change_y_position
  358.     select(item_max - 1)
  359.   end
  360.  
  361.   #--------------------------------------------------------------------------
  362.   # change_y_position  这里的数字可以改变显示条的位置,数字越小越低。
  363.   #--------------------------------------------------------------------------
  364.   def change_y_position
  365.     maximum = [item_max, YEA::EVENT_WINDOW::MAX_LINES].min
  366.     self.y = Graphics.height - fitting_height(maximum) - 180
  367.   end
  368.  
  369.   #--------------------------------------------------------------------------
  370.   # refresh
  371.   #--------------------------------------------------------------------------
  372.   def refresh
  373.     create_contents
  374.     draw_all_items
  375.   end
  376.  
  377.   #--------------------------------------------------------------------------
  378.   # draw_item
  379.   #--------------------------------------------------------------------------
  380.   def draw_item(index)
  381.     $game_temp.clear_event_window_data if $game_temp.event_window_data.nil?
  382.     item = $game_temp.event_window_data[index]
  383.     return if item.nil?
  384.     rect = item_rect(index)
  385.     draw_background(rect)
  386.     rect.x += 4
  387.     rect.width -= 8
  388.     draw_text_ex(rect.x, rect.y, item)
  389.   end
  390.  
  391.   #--------------------------------------------------------------------------
  392.   # draw_background
  393.   #--------------------------------------------------------------------------
  394.   def draw_background(rect)
  395.     back_colour1 = Color.new(72, 209,204, 62)
  396.     back_colour2 = Color.new(0, 0, 0, 0)
  397.     contents.gradient_fill_rect(rect, back_colour1, back_colour2)
  398.   end
  399.  
  400. end # Window_EventWindow
  401.  
  402. #==============================================================================
  403. # ■ Scene_Map
  404. #==============================================================================
  405.  
  406. class Scene_Map < Scene_Base
  407.  
  408.   #--------------------------------------------------------------------------
  409.   # alias method: create_all_windows
  410.   #--------------------------------------------------------------------------
  411.   alias scene_map_create_all_windows_event_window create_all_windows
  412.   def create_all_windows
  413.     scene_map_create_all_windows_event_window
  414.     create_event_window
  415.   end
  416.  
  417.   #--------------------------------------------------------------------------
  418.   # new method: create_event_window
  419.   #--------------------------------------------------------------------------
  420.   def create_event_window
  421.     @event_window = Window_EventWindow.new
  422.   end
  423.  
  424.   #--------------------------------------------------------------------------
  425.   # new method: event_window_add_text
  426.   #--------------------------------------------------------------------------
  427.   def event_window_add_text(text)
  428.     Sound.play_shop
  429.     @event_window.add_text(text)
  430.   end
  431.  
  432.   #--------------------------------------------------------------------------
  433.   # alias method: post_transfer
  434.   #--------------------------------------------------------------------------
  435.   alias scene_map_post_transfer_ew post_transfer
  436.   def post_transfer
  437.     $game_temp.clear_event_window_data if YEA::EVENT_WINDOW::NEW_MAP_CLEAR
  438.     @event_window.instant_hide
  439.     scene_map_post_transfer_ew
  440.   end
  441.  
  442. end # Scene_Map
  443.  
  444. #==============================================================================
  445. #
  446. # ▼ End of File
  447. #
  448. #==============================================================================


(碎碎念)
后面这个脚本因为有贴出处,所以在下还去发布组网页找了半天,结果发布组现在好像只有MV和MZ的插件了,va的插件完全找不到……
如果有大佬直接拉到最下面看的话还请返回上面_(:₃」∠)_,因为这边只是在下的废话而已。
话说va是不是时代的眼泪了啊 一搜帖子全都是十年甚至九年以前的东西了

Lv6.析梦学徒

老鹰

梦石
40
星屑
33422
在线时间
6553 小时
注册时间
2012-5-26
帖子
3178

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

2
发表于 2022-9-21 09:37:56 | 只看该作者
后面这个yanfly的早就转移到github上作为备注
https://github.com/Archeia/YEARepo

具体就是你看它们怎么改的command,你就仿照去改gain_item
但是直接改会导致显示两次得失提示,所以推荐把gain_item复制一份再改个名,你用改名后的方法去增加物品提示

毕竟时间已经这么久了……还在用的真的就是情怀,或者没法换(因为工程无法迁移)

点评

咋不直接推介你的得失提示脚本呢2333  发表于 2022-9-21 11:43
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
882
在线时间
83 小时
注册时间
2022-9-13
帖子
14
3
 楼主| 发表于 2022-9-21 11:05:50 | 只看该作者
百里_飞柳 发表于 2022-9-21 09:37
后面这个yanfly的早就转移到github上作为备注
https://github.com/Archeia/YEARepo

救命
在下真的尽力改了,但是完全改不来……不是没效果就是报错。。
command指令是在game_interpreter父类下的,但是gain_item这个函数只能在game_party里找到定义,在interpreter里只能找到它的使用……
然后如果直接在物品得失脚本里贴上def gain_item,再把得失脚本里对command的修改复制过来,也没有效果……
而像这样
  1.   alias_method :gain_without_message,  :gain_item
复制代码

在# 别名:不显示提示窗口的事件指令下添加gain_item的分类的话,它就会报错说interpreter下找不到gain_item。
所以到底应该怎么改啊
是在物品得失脚本里新引用Game_Party,然后把该脚本对Interpreter中command处理的窗口格式都贴到引用的Party下,再复制command的改写给gain_item
还是直接去Game_Party脚本里面把gain_item给改掉?
因为实在对脚本没什么接触,所以目前只有这两个思路(个人感觉都不太靠谱……)
大佬有没有好的例子让在下学习一下……
如果能帮忙改一下就最好了(被打)
回复 支持 反对

使用道具 举报

Lv6.析梦学徒

老鹰

梦石
40
星屑
33422
在线时间
6553 小时
注册时间
2012-5-26
帖子
3178

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

4
发表于 2022-9-21 11:46:28 | 只看该作者
本帖最后由 百里_飞柳 于 2022-9-21 11:49 编辑
渊呒紟 发表于 2022-9-21 11:05
救命
在下真的尽力改了,但是完全改不来……不是没效果就是报错。。
command指令是在game_inter ...




就拿 yanfly 的物品得失提示来说,
检查它的 command_126 方法(这个是默认RGSS里对应 事件指令-获得物品 的脚本)
它新增了两句
  1.     $game_temp.clear_event_window_data  # 清除之前的得失提示文本
  2.     event_window_make_item_text($data_items[@params[0]], value)  # 构建当前指令的得失提示文本
复制代码




于是,你可以仿照给 $game_party 的获得物品方法也加上这个
  1. class Game_Party
  2.   #alias yea_show_gain_gain_item gain_item
  3.   #def gain_item(item, amount, include_equip = false)
  4.   #  yea_show_gain_gain_item(item, amount, include_equip)  # 确保旧的物品得失处理不受影响
  5.   #  event_window_make_item_text(item, amount)
  6.   #end
  7.   # 不过上面这种会导致物品得失提示两次,所以推荐新建一个方法,专门用于你自己调用
  8.   def my_gain_item(item, amount, include_equip = false)
  9.       gain_item(item, amount, include_equip)
  10.       event_window_make_item_text(item, amount)
  11.   end
  12. end
复制代码


但注意 event_window_make_item_text 方法只在 Game_Interpreter 里有,所以还要把它复制给 Game_Party 才行
  1. class Game_Party
  2.   #--------------------------------------------------------------------------
  3.   # new method: event_window_make_item_text
  4.   #--------------------------------------------------------------------------
  5.   def event_window_make_item_text(item, value)
  6.     return unless SceneManager.scene_is?(Scene_Map)
  7.     return if Switch.hide_event_window
  8.     if value > 0
  9.       text = YEA::EVENT_WINDOW::FOUND_TEXT
  10.     elsif value < 0
  11.       text = YEA::EVENT_WINDOW::LOST_TEXT
  12.     else; return
  13.     end
  14.     text += sprintf("\ei[%d]%s", item.icon_index, item.name)
  15.     if value.abs > 1
  16.       fmt = YEA::EVENT_WINDOW::AMOUNT_TEXT
  17.       text += sprintf(fmt, value.abs.group)
  18.     end
  19.     event_window_add_text(text)
  20.   end

  21.   #--------------------------------------------------------------------------
  22.   # new method: event_window_add_text
  23.   #--------------------------------------------------------------------------
  24.   def event_window_add_text(text)
  25.     return unless SceneManager.scene_is?(Scene_Map)
  26.     return if Switch.hide_event_window
  27.     text = YEA::EVENT_WINDOW::HEADER_TEXT + text
  28.     text += YEA::EVENT_WINDOW::CLOSER_TEXT
  29.     SceneManager.scene.event_window_add_text(text)
  30.   end

  31. end
复制代码




此外,由于它的写法,才会连续多个得失提示文本时,只显示最后一个的问题,因为每次物品获得时,都清除了旧的
把里面的 $game_temp.clear_event_window_data 注释掉,也就是前面加个 # 符号,变成
  1. #$game_temp.clear_event_window_data
复制代码

这样每次都不清除之前的,也就能叠加显示

但也有问题,好久之前的得失记录都还留存着,那肯定不行,要么每次手动添加这一句清除记录的脚本到 事件指令-脚本 中,要么借用其它事件指令来同时清除:
  1. class Game_Interpreter
  2.   alias yea_item_gain_command_108 command_108
  3.   def command_108
  4.      yea_item_gain_command_108  # 旧的添加注释的指令,保证之前的功能顺利执行
  5.      $game_temp.clear_event_window_data  # 添加的新内容,清除得失提示的记录
  6.   end
  7. end
复制代码

这样,你在物品得失后添加一个注释,里面内容随便,就清除了记录,下一次开启得失提示框时,就不会再显示旧记录了

评分

参与人数 1+1 收起 理由
渊呒紟 + 1 认可答案

查看全部评分

回复 支持 1 反对 0

使用道具 举报

Lv2.观梦者

梦石
0
星屑
882
在线时间
83 小时
注册时间
2022-9-13
帖子
14
5
 楼主| 发表于 2022-9-21 13:31:44 | 只看该作者
百里_飞柳 发表于 2022-9-21 11:46


就拿 yanfly 的物品得失提示来说,
检查它的 command_126 方法(这个是默认RGSS里对应 事件指令-获 ...

鹰佬,把你给的指令贴进yanfly的物品提示里之后,如果用新建的方法则没有反应
如果用会导致提示出现两次的方法,就会……
  1. text += sprintf("\ei[%d]%s", item.icon_index, item.name)
复制代码

这一行报错了
说undifined method 'icon_index' for nil:NilClass
在下翻了翻Game_Party,确实没看到同样的表达,在Game_Interpreter里似乎也没有。
为什么会出现这样的情况呢

点评

创建新方法后,调用也是用新方法 $game_party.my_gain_item(item, v),而 item 是替换成 $data_items[1]这样的  发表于 2022-9-21 14:47
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
882
在线时间
83 小时
注册时间
2022-9-13
帖子
14
6
 楼主| 发表于 2022-9-21 17:34:16 | 只看该作者
百里_飞柳 发表于 2022-9-21 11:46


就拿 yanfly 的物品得失提示来说,
检查它的 command_126 方法(这个是默认RGSS里对应 事件指令-获 ...

好的,解决了
万分感谢老鹰老师的帮助
(解决完之后再回头看自己的问题顿感在下是个呆瓜qwq)
实在是感激不尽!祝大佬心想事成万事如意wwww
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-2 05:55

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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