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

Project1

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

[已经过期] 菜单使用物品触发公共事件如何不退出物品栏?

[复制链接]

Lv2.观梦者

梦石
0
星屑
373
在线时间
54 小时
注册时间
2018-8-20
帖子
15
跳转到指定楼层
1
发表于 2020-6-5 23:57:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我设置了使用物品触发公共事件,然后物品栏就消失了。不能像使用恢复药那样批量使用,导致批量使用非常不方便。请问大家有何建议?
头像被屏蔽

Lv4.逐梦者 (禁止发言)

梦石
0
星屑
5701
在线时间
922 小时
注册时间
2013-8-29
帖子
1468
2
发表于 2020-6-6 00:19:26 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
373
在线时间
54 小时
注册时间
2018-8-20
帖子
15
3
 楼主| 发表于 2020-6-6 00:39:56 | 只看该作者
本帖最后由 yc666666 于 2020-6-6 00:46 编辑
chanszeman1018 发表于 2020-6-6 00:19
我也想知道為什麼畎認代碼中,執行完公共事件得回到地图。
是不是不回到地图的話,会引发其他问题呢?
...


兄弟,我试了一下,这样的话如果批量使用物品,最后离开菜单只会结算一次公共事件...很奇怪...

点评

只结算一次是因为公共事件的机制是通过Game_Temp将下一个要执行的公共事件的编号储存起来,修改后即使多次改变也只会保留最后一个的编号  发表于 2020-6-6 01:07
2L點評中,日历大佬給解釋了.2L的脚本別用了.  发表于 2020-6-6 00:50
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
10
星屑
39445
在线时间
1914 小时
注册时间
2010-11-14
帖子
3315

R考场第七期纪念奖

4
发表于 2020-6-6 00:51:48 | 只看该作者
因为公共事件的解释器在Game_Map里,而只有Scene_Map会更新Game_Map,所以必须返回Scene_Map执行。
虽然可以自己改代码来强行让它在其他Scene执行,但是不懂脚本的人无法控制这样做带来的风险。
用头画头像,用脚写脚本
回复 支持 反对

使用道具 举报

Lv6.析梦学徒

老鹰

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

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

5
发表于 2020-6-6 11:51:36 | 只看该作者
这是因为菜单里没法执行事件啊
回复药那种只是单纯的给角色加血,但公共事件可就复杂多了,谁知道你会在公共事件里做什么(x)

所以就变成了最多预定一个公共事件,如果有预定就立马回到地图里执行它,也是最大限度的妥协了吧

如果你有很多这种道具,可能你需要的是 地图使用道具 的快捷菜单之类的插件
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
1
星屑
14506
在线时间
2086 小时
注册时间
2017-9-28
帖子
662
6
发表于 2020-6-6 17:54:01 | 只看该作者
  1. =begin
  2. #===============================================================================
  3. Title: 场景解释器
  4. Author: Hime
  5. Date: Nov 21, 2015
  6. --------------------------------------------------------------------------------
  7. ** Change log
  8. Nov 21, 2015
  9.    - fixed bug where item menu crashes when using common event
  10. Nov 17, 2015
  11.    - create scene message windows, not normal windows
  12. Oct 24, 2015
  13.    - implement callback function for scene interpreter
  14. Sep 18, 2015
  15.    - fixed major memory leak issues reported by Sixth
  16. May 26, 2015
  17.    - fixed issue with common events called by scene interpreter
  18. Jan 27, 2015
  19.    - experimental cross-scene common events
  20. Nov 19, 2014
  21.    - Interpreter is re-created on reset so commands don't continue to run from
  22.      the previous session
  23. Oct 13, 2014
  24.    - added support for disabling other windows when interpreter takes control
  25.    - moved interpreter into SceneManager as a global scene interpreter
  26. Sep 5, 2013
  27.    - fixed bug where common events returning to map did not execute properly
  28. Apr 24, 2013
  29.    - fixed bug where game crashed when no common events were reserved
  30. Apr 3, 2013
  31.    - Added comment to determine scene to run common event
  32. Mar 30, 2013
  33.    - Initial release
  34. --------------------------------------------------------------------------------   
  35. ** Terms of Use
  36. * Free to use in non-commercial projects
  37. * Contact me for commercial use
  38. * No real support. The script is provided as-is
  39. * Will do bug fixes, but no compatibility patches
  40. * Features may be requested but no guarantees, especially if it is non-trivial
  41. * Credits to Hime Works in your project
  42. * Preserve this header
  43. --------------------------------------------------------------------------------
  44. ** 介绍

  45. 本脚本可以在任何场景中添加一个解释器和文本窗口,这样你就可以在任何场景中执行
  46. 公共事件了. (例如,默认下,如果你在技能效果中添加公共事件,在地图里使用技能
  47. 以后,会回到地图,然后才执行公共事件。添加场景解释器后,公共事件会在技能场景
  48. 中执行,场景不会切换到地图。)

  49. --------------------------------------------------------------------------------
  50. ** 安装

  51. 放在插件脚本之下,Main之上. 还有建议放在其他自定义脚本之上.

  52. --------------------------------------------------------------------------------
  53. ** 使用方法

  54. 公共事件页使用注释:

  55.    <run scene: current>
  56.   
  57. #===============================================================================
  58. =end
  59. $imported = {} if $imported.nil?
  60. $imported["TH_SceneInterpreter"] = true
  61. #===============================================================================
  62. # ** Configuration
  63. #===============================================================================
  64. module TH
  65.   module Scene_Interpreter
  66.    
  67.     # Run common events directly in scene without going to map
  68.     No_Return_Scene = true
  69.    
  70.     Run_Regex = /<run[-_ ]scene:\s*(\w+)/i
  71.   end
  72. end
  73. #===============================================================================
  74. # ** Rest of Script
  75. #===============================================================================
  76. module RPG
  77.   class CommonEvent
  78.    
  79.     #---------------------------------------------------------------------------
  80.     # Which scene to run this common event
  81.     #---------------------------------------------------------------------------
  82.     def run_scene
  83.       return @run_scene unless @run_scene.nil?
  84.       parse_comments_scene_interpreter
  85.       return @run_scene
  86.     end
  87.    
  88.     #---------------------------------------------------------------------------
  89.     # Parse the commands for a Run Scene comment
  90.     #---------------------------------------------------------------------------
  91.     def parse_comments_scene_interpreter
  92.       # just an arbitrary default value
  93.       @run_scene = :map
  94.       @list.each do |cmd|
  95.         if cmd.code == 108 && cmd.parameters[0] =~ TH::Scene_Interpreter::Run_Regex
  96.           @run_scene = $1.downcase.to_sym
  97.         end
  98.       end
  99.     end
  100.   end
  101. end

  102. module SceneManager
  103.   
  104.   class << self
  105.     alias :th_scene_interpreter_run :run
  106.   end
  107.   
  108.   def self.run   
  109.     init_interpreter
  110.     th_scene_interpreter_run
  111.   end
  112.   
  113.   def self.init_interpreter
  114.     @interpreter = Game_SceneInterpreter.new   
  115.   end
  116.   
  117.   def self.interpreter
  118.     @interpreter
  119.   end
  120. end

  121. #-------------------------------------------------------------------------------
  122. # A special interpreter for scenes
  123. #-------------------------------------------------------------------------------
  124. class Game_SceneInterpreter < Game_Interpreter
  125.   attr_accessor :callback
  126.   
  127.   def pause_windows
  128.     SceneManager.scene.store_active_windows
  129.   end
  130.   
  131.   def unpause_windows
  132.     SceneManager.scene.restore_active_windows
  133.   end
  134.   
  135.   def update
  136.     @fiber.resume if @fiber
  137.   end
  138.   
  139.   alias :th_scene_interpreter_run :run
  140.   def run
  141.     th_scene_interpreter_run
  142.     if @callback
  143.       @callback.call
  144.       @callback = nil
  145.     end
  146.   end
  147. end

  148. class Scene_Base
  149.   
  150.   alias :th_scene_interpreter_start :start
  151.   def start
  152.     @active_windows = []
  153.     @windows = []
  154.     th_scene_interpreter_start
  155.     create_message_window
  156.   end
  157.   
  158.   alias :th_scene_interpreter_post_start :post_start
  159.   def post_start
  160.     instance_variables.each do |varname|
  161.       ivar = instance_variable_get(varname)
  162.       if !ivar.is_a?(Window_SceneMessage) && ivar.is_a?(Window)
  163.         @windows << ivar
  164.       end
  165.     end
  166.     th_scene_interpreter_post_start
  167.   end
  168.   
  169.   #-----------------------------------------------------------------------------
  170.   # Create message window
  171.   #-----------------------------------------------------------------------------
  172.   def create_message_window
  173.     @message_window = Window_SceneMessage.new
  174.   end
  175.   
  176.   alias :th_scene_interpreter_update :update
  177.   def update
  178.     th_scene_interpreter_update
  179.     update_interpreter
  180.   end
  181.   
  182.   #-----------------------------------------------------------------------------
  183.   # Run any common events
  184.   #-----------------------------------------------------------------------------
  185.   def update_interpreter
  186.    
  187.     loop do      
  188.       SceneManager.interpreter.update      
  189.       return if SceneManager.interpreter.running?
  190.       
  191.       # Don't setup the common event if it doesn't run in the current scene
  192.       return if $game_temp.common_event_reserved? && $data_common_events[$game_temp.common_event_id].run_scene != :current
  193.       
  194.       if SceneManager.interpreter.setup_reserved_common_event
  195.         store_active_windows
  196.       else
  197.         restore_active_windows
  198.         return
  199.       end
  200.     end   
  201.   end
  202.   
  203.   #-----------------------------------------------------------------------------
  204.   # Go through all windows and store them if they're active
  205.   #-----------------------------------------------------------------------------
  206.   def store_active_windows
  207.     restore_active_windows
  208.     @windows.each do |win|
  209.       if win.active
  210.         @active_windows.push(win)
  211.         win.deactivate
  212.       end
  213.     end   
  214.   end
  215.   
  216.   def restore_active_windows
  217.     @active_windows.each do |win|
  218.       win.activate
  219.     end
  220.     @active_windows = []
  221.   end
  222. end

  223. class Scene_ItemBase < Scene_MenuBase
  224.   alias :th_scene_interpreter_check_common_event :check_common_event
  225.   def check_common_event
  226.     return if !$game_temp.common_event_reserved? || ($game_temp.common_event_reserved? && $data_common_events[$game_temp.common_event_id].run_scene == :current)
  227.     SceneManager.interpreter.callback = Proc.new { @actor_window.refresh unless @actor_window.disposed? }
  228.     th_scene_interpreter_check_common_event
  229.   end
  230. end

  231. class Window_SceneMessage < Window_Message
  232.   
  233.   #-----------------------------------------------------------------------------
  234.   # These are all random z values
  235.   #-----------------------------------------------------------------------------
  236.   alias :th_scene_interpreter_initialize :initialize
  237.   def initialize
  238.     super
  239.     self.z = 999900
  240.     @gold_window.z = 999900
  241.     @item_window.z = 999900
  242.     @number_window.z = 999900
  243.     @choice_window.z = 999900
  244.   end
  245. end

  246. class Game_Interpreter
  247.   attr_reader :index
  248.   
  249.   alias :th_scene_interpreter_command_117 :command_117
  250.   def command_117
  251.     common_event = $data_common_events[@params[0]]
  252.     if common_event && common_event.run_scene == :current      
  253.       # hack solution. When a common event is called, we check whether
  254.       # it should run in the current scene or not. If it should, we delegate
  255.       # it to the scene interpreter. However, common events from the
  256.       # scene interpreter run into problems
  257.       if self.is_a?(Game_SceneInterpreter)
  258.         child = Game_SceneInterpreter.new(@depth + 1)
  259.         child.setup(common_event.list, same_map? ? @event_id : 0)
  260.         child.run
  261.       else
  262.         SceneManager.interpreter.setup(common_event.list)
  263.         Fiber.yield while SceneManager.interpreter.running?
  264.       end
  265.     else
  266.       th_scene_interpreter_command_117
  267.     end
  268.   end
  269. end

  270. # Memory leak situation is created when the following scenes create their own
  271. # message windows, overwriting the one created when the scene started. Issue reported and
  272. # fix provided by Sixth
  273. class Scene_Map
  274.   def create_message_window
  275.     @message_window = Window_SceneMessage.new unless @message_window && !@message_window.disposed?
  276.   end
  277. end

  278. class Scene_Battle
  279.   def create_message_window
  280.     @message_window = Window_SceneMessage.new unless @message_window && !@message_window.disposed?
  281.   end
  282. end
复制代码
VA外站脚本汉化群:226308173   |    部分远古文件备份:https://wwzv.lanzoue.com/b02rac5pc  密码:acgm
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6707
在线时间
591 小时
注册时间
2017-11-10
帖子
679

极短21参与

7
发表于 2020-12-17 11:31:10 | 只看该作者

老猫啊,这个脚本在使用贵重品触发公共事件后会卡住不动,可能是里面没有返回上一级菜单的指令吧。

点评

老猫只是搬运工...你问他也答不到你...  发表于 2020-12-17 11:41
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
24394
在线时间
5061 小时
注册时间
2016-3-8
帖子
1622
8
发表于 2020-12-17 11:49:20 | 只看该作者
本帖最后由 alexncf125 于 2020-12-17 12:04 编辑
BCJT 发表于 2020-12-17 11:31
老猫啊,这个脚本在使用贵重品触发公共事件后会卡住不动,可能是里面没有返回上一级菜单的指令吧。{:4_11 ...


刚简单测试了一下,
我这边没出现"使用贵重品触发公共事件后会卡住不动"的情形

你试试把贵重品改成普通品, 看看会不会仍出现上述情形
还是出现上述情形的话, 那就应该是呼叫的那个公共事件有问题了
再不就是与其他脚本冲突了

点评

可能是我的事件有冲突了- _ - !  发表于 2020-12-17 21:29
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-6 02:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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