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

Project1

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

[已经解决] YEA的气泡对话框可不可以在本事件的位置显示对话框?

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1971
在线时间
926 小时
注册时间
2015-10-26
帖子
356

开拓者

跳转到指定楼层
1
发表于 2018-10-10 09:15:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
脚本里面注释了 \bm[x] 是在x号事件的位置显示对话框,如果x为0,就在玩家的位置显示。
求教下有没有定义在“本事件”位置显示对话框的方法?

脚本如下

RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ¥ Yami Engine Ace - Pop Message
  4. # -- Last Updated: 2012.06.07
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YSE-PopMessage"] = true
  12. #==============================================================================
  13. # ¥ Updates
  14. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  15. # 2012.06.07 - Fixed Compatible: YEA - Ace Message System.
  16. # 2012.05.11 - Fixed Message Position.
  17. #            - Remove Requirement: YSE - Fix Events Order.
  18. # 2012.05.07 - Fixed Face position.
  19. #            - Added Requirement: YSE - Fix Events Order.
  20. # 2012.04.06 - You can change Bubble Tag filename.
  21. # 2012.03.28 - Fixed Default Message Position and Sizes.
  22. # 2012.03.27 - Fixed Default Message.
  23. # 2012.03.27 - Added Bubble Tag.
  24. # 2012.03.25 - Fixed Escape Message.
  25. # 2012.03.24 - Fixed Battle Message.
  26. # 2012.03.24 - Rewrote script.
  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/‘fÞ but above ¥ Main. Remember to save.
  33. #
  34. # -----------------------------------------------------------------------------
  35. # Message Window text Codes - These go inside of your message window.
  36. # -----------------------------------------------------------------------------
  37. #  Position:   Effect:
  38. #    \bm[x]    - Sets Message Window position to event x. *Note
  39. #    \cbm      - Cancel bubble message.
  40. #
  41. #              *Note: Set to 0 to sets position to Game Player.
  42. #
  43. #==============================================================================
  44. # ¥ Compatibility
  45. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  46. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  47. # it will run with RPG Maker VX without adjusting.
  48. #
  49. #==============================================================================
  50.  
  51. module YSE
  52.   module POP_MESSAGE
  53.  
  54.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  55.     # - Visual Settings -
  56.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  57.     LIMIT = { # Start.
  58.       :limit_width    =>  0,  # Set to 0 to disable limit.
  59.       :limit_line     =>  6,  # Set to 0 to disable limit.
  60.     } # End.
  61.  
  62.     POSITION = { # Start.
  63.       :x_buffer       =>  0,
  64.       :y_buffer       =>  -36,
  65.       :face_x_buffer  =>  8,
  66.       :face_y_buffer  =>  24,
  67.       :tag_y_buffer   =>  -6,
  68.       :name_x_buffer  =>  112, # Require YEA - Message System.
  69.     } # End.
  70.  
  71.     EFFECT = { # Start.
  72.       :fade_face       =>  true,
  73.       :move_face       =>  true,
  74.       :use_bubble_tag  =>  true,
  75.       :bubble_tag_name => "BubbleTag",
  76.     } # End.
  77.  
  78.   end
  79. end
  80.  
  81. #==============================================================================
  82. # ¥ Editting anything past this point may potentially result in causing
  83. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  84. # halitosis so edit at your own risk.
  85. #==============================================================================
  86.  
  87. #==============================================================================
  88. # ¡ Spriteset_Map
  89. #==============================================================================
  90.  
  91. class Spriteset_Map
  92.  
  93.   #--------------------------------------------------------------------------
  94.   # public instance variables
  95.   #--------------------------------------------------------------------------
  96.   attr_accessor :character_sprites
  97.  
  98. end # Spriteset_Map
  99.  
  100. #==============================================================================
  101. # ¡ Window_Message_Face
  102. #==============================================================================
  103.  
  104. class Window_Message_Face < Window_Base
  105.  
  106.   #--------------------------------------------------------------------------
  107.   # initialize
  108.   #--------------------------------------------------------------------------
  109.   def initialize
  110.     super(0, 0, 120, 120)
  111.     self.opacity = 0
  112.     @face_name = ""
  113.     @face_index = 0
  114.     @move_x = 0
  115.     close
  116.   end
  117.  
  118.   #--------------------------------------------------------------------------
  119.   # message_window=
  120.   #--------------------------------------------------------------------------
  121.   def message_window=(window)
  122.     @message_window = window
  123.   end
  124.  
  125.   #--------------------------------------------------------------------------
  126.   # set_face
  127.   #--------------------------------------------------------------------------
  128.   def set_face
  129.     contents.clear
  130.     return unless @message_window
  131.     if !$game_message.face_name.empty?
  132.       draw_face($game_message.face_name, $game_message.face_index, 0, 0)
  133.       set_position
  134.       show_face
  135.     else
  136.       hide_face
  137.     end
  138.   end
  139.  
  140.   #--------------------------------------------------------------------------
  141.   # set_position
  142.   #--------------------------------------------------------------------------
  143.   def set_position
  144.     return unless @message_window
  145.     self.x = @message_window.x
  146.     self.y = @message_window.y - 96
  147.     self.x += YSE::POP_MESSAGE::POSITION[:face_x_buffer]
  148.     self.y += YSE::POP_MESSAGE::POSITION[:face_y_buffer]
  149.     self.y += (@message_window.real_lines - 1) * 30
  150.     self.z = @message_window.z + 1
  151.     if (@face_name != $game_message.face_name || @face_index != $game_message.face_index)
  152.       if YSE::POP_MESSAGE::EFFECT[:move_face]
  153.         @move_x = 30
  154.         self.x -= 30
  155.       end
  156.       @face_name = $game_message.face_name
  157.       @face_index = $game_message.face_index
  158.       self.contents_opacity = 0 if YSE::POP_MESSAGE::EFFECT[:fade_face]
  159.     end
  160.   end
  161.  
  162.   #--------------------------------------------------------------------------
  163.   # show_face
  164.   #--------------------------------------------------------------------------
  165.   def show_face
  166.     open
  167.   end
  168.  
  169.   #--------------------------------------------------------------------------
  170.   # hide_face
  171.   #--------------------------------------------------------------------------
  172.   def hide_face
  173.     contents.clear
  174.     close
  175.   end
  176.  
  177.   #--------------------------------------------------------------------------
  178.   # update
  179.   #--------------------------------------------------------------------------
  180.   def update
  181.     super
  182.     self.contents_opacity += 15 if self.contents_opacity < 255
  183.     unless @move_x <= 0
  184.       self.x += 2
  185.       @move_x -= 2
  186.     end
  187.   end
  188.  
  189. end # Sprite_Message_Face
  190.  
  191. #==============================================================================
  192. # ¡ Window_Message
  193. #==============================================================================
  194.  
  195. class Window_Message < Window_Base
  196.  
  197.   #--------------------------------------------------------------------------
  198.   # new method: face_window=
  199.   #--------------------------------------------------------------------------
  200.   def face_window=(window)
  201.     @face_window = window
  202.   end
  203.  
  204.   #--------------------------------------------------------------------------
  205.   # new method: bubble_tag=
  206.   #--------------------------------------------------------------------------
  207.   def bubble_tag=(sprite)
  208.     @bubble_tag = sprite
  209.   end
  210.  
  211.   #--------------------------------------------------------------------------
  212.   # new method: message_escape_characters_pop_message
  213.   #--------------------------------------------------------------------------
  214.   def message_escape_characters_pop_message(result)
  215.     result.gsub!(/\eBM\[(\d+)\]/i) { event_pop_message_setup($1.to_i, false) }
  216.     result.gsub!(/\eBMF\[(\d+)\]/i) { event_pop_message_setup($1.to_i, true) }
  217.     result.gsub!(/\eCBM/i) { event_pop_message_setup(nil, false) }
  218.     result
  219.   end
  220.  
  221.   #--------------------------------------------------------------------------
  222.   # alias method: convert_escape_characters
  223.   #--------------------------------------------------------------------------
  224.   alias yse_convert_escape_characters_pm convert_escape_characters
  225.   def convert_escape_characters(text)
  226.     result = yse_convert_escape_characters_pm(text)
  227.     result = message_escape_characters_pop_message(result)
  228.     result
  229.   end
  230.  
  231.   #--------------------------------------------------------------------------
  232.   # new method: event_pop_message_setup
  233.   #--------------------------------------------------------------------------
  234.   def event_pop_message_setup(event_id, follower = false)
  235.     if follower && $game_player.followers[event_id].nil?
  236.       @event_pop_id = nil
  237.       @event_pop_follower = false
  238.       return ""
  239.     end
  240.     @event_pop_follower = follower
  241.     @event_pop_id = event_id
  242.     return ""
  243.   end
  244.  
  245.   #--------------------------------------------------------------------------
  246.   # new method: set_face_position
  247.   #--------------------------------------------------------------------------
  248.   def set_face_position
  249.     return unless SceneManager.scene_is?(Scene_Map)
  250.     return unless @event_pop_id
  251.     return unless @face_window
  252.     contents.clear
  253.     @face_window.set_face
  254.     return unless $imported["YEA-MessageSystem"]
  255.     return if @face_window.close?
  256.     #@name_window.x = self.x + YSE::POP_MESSAGE::POSITION[:face_x_buffer] + YSE::POP_MESSAGE::POSITION[:name_x_buffer] if (@name_position == 1 || @name_position == 2)
  257.   end
  258.  
  259.   #--------------------------------------------------------------------------
  260.   # alias method: new_page
  261.   #--------------------------------------------------------------------------
  262.   alias window_message_new_page_pm_yse new_page
  263.   def new_page(text, pos)
  264.     window_message_new_page_pm_yse(text, pos)
  265.     set_face_position
  266.   end
  267.  
  268.   #--------------------------------------------------------------------------
  269.   # alias method: close
  270.   #--------------------------------------------------------------------------
  271.   alias pop_message_close close
  272.   def close
  273.     pop_message_close
  274.     return unless SceneManager.scene_is?(Scene_Map)
  275.     return unless @event_pop_id
  276.     @event_pop_id = nil
  277.     @event_pop_follower = false
  278.     @face_window.hide_face
  279.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  280.     @bubble_tag.visible = false if @bubble_tag
  281.   end
  282.  
  283.   #--------------------------------------------------------------------------
  284.   # alias method: open_and_wait
  285.   #--------------------------------------------------------------------------
  286.   alias pop_message_open_and_wait open_and_wait
  287.   def open_and_wait
  288.     pop_message_open_and_wait
  289.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  290.     @bubble_tag.visible = true if @event_pop_id && @bubble_tag
  291.   end
  292.  
  293.   #--------------------------------------------------------------------------
  294.   # alias method: process_all_text
  295.   #--------------------------------------------------------------------------
  296.   alias pop_message_process_all_text process_all_text
  297.   def process_all_text
  298.     @event_pop_id = nil
  299.     convert_escape_characters($game_message.all_text)
  300.     update_placement
  301.     adjust_pop_message($game_message.all_text)
  302.     pop_message_process_all_text
  303.   end
  304.  
  305.   #--------------------------------------------------------------------------
  306.   # alias method: update_placement
  307.   #--------------------------------------------------------------------------
  308.   alias event_pop_message_update_placement update_placement
  309.   def update_placement
  310.     if SceneManager.scene_is?(Scene_Map)
  311.       if @event_pop_id.nil?
  312.         fix_default_message
  313.         event_pop_message_update_placement
  314.       elsif @event_pop_id == 0
  315.         character = $game_player
  316.         self.y = character.screen_y - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  317.         self.x = character.screen_x - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  318.         fix_position_bubble(character)
  319.         set_bubble_tag(character)
  320.       elsif @event_pop_id > 0
  321.         hash = @event_pop_follower ? $game_player.followers : $game_map.events
  322.         character = hash[@event_pop_id]
  323.         self.y = character.screen_y - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  324.         self.x = character.screen_x - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  325.         fix_position_bubble(character)
  326.         set_bubble_tag(character)
  327.       end
  328.     else
  329.       event_pop_message_update_placement
  330.     end
  331.   end
  332.  
  333.   #--------------------------------------------------------------------------
  334.   # new method: fix_default_message
  335.   #--------------------------------------------------------------------------
  336.   def fix_default_message
  337.     self.width = window_width
  338.     self.height = window_height
  339.     self.x = 0
  340.     @face_window.hide_face if @face_window
  341.     create_contents
  342.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  343.     @bubble_tag.visible = false if @bubble_tag
  344.   end
  345.  
  346.   #--------------------------------------------------------------------------
  347.   # new method: fix_position_bubble
  348.   #--------------------------------------------------------------------------
  349.   def fix_position_bubble(character)
  350.     end_x = self.x + self.width
  351.     end_y = self.y + self.height
  352.     self.x = 0 if self.x < 0
  353.     self.y = character.screen_y if self.y < 0
  354.     self.x = Graphics.width - self.width if end_x > Graphics.width
  355.     self.y = Graphics.height - self.height if end_y > Graphics.height
  356.   end
  357.  
  358.   #--------------------------------------------------------------------------
  359.   # new method: set_bubble_tag
  360.   #--------------------------------------------------------------------------
  361.   def set_bubble_tag(character)
  362.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  363.     return unless @bubble_tag
  364.     up = self.y == character.screen_y
  365.     self.y += up ? @bubble_tag.height / 2 : [email]-@bubble_tag.height[/email] / 2
  366.     @bubble_tag.x = character.screen_x - @bubble_tag.width / 2
  367.     if up
  368.       @bubble_tag.src_rect.set(0, @bubble_tag.height, @bubble_tag.width, @bubble_tag.height)
  369.       @bubble_tag.y = self.y - @bubble_tag.height - YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  370.     else
  371.       @bubble_tag.src_rect.set(0, 0, @bubble_tag.width, @bubble_tag.height)
  372.       @bubble_tag.y = self.y + self.height + YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  373.     end
  374.   end
  375.  
  376.   #--------------------------------------------------------------------------
  377.   # new method: cal_number_line
  378.   #--------------------------------------------------------------------------
  379.   def cal_number_line(text)
  380.     result = 0
  381.     text.each_line { result += 1 }
  382.     return result
  383.   end
  384.  
  385.   #--------------------------------------------------------------------------
  386.   # new method: cal_width_line
  387.   #--------------------------------------------------------------------------
  388.   def cal_width_line(text)
  389.     result = 0
  390.     text.each_line { |line|
  391.       result = text_size(line).width if result < text_size(line).width
  392.     }
  393.     return result
  394.   end
  395.  
  396.   #--------------------------------------------------------------------------
  397.   # alias method: adjust_message_window_size
  398.   #--------------------------------------------------------------------------
  399.   if $imported["YEA-MessageSystem"]
  400.   alias yse_pop_message_adjust_message_window_size adjust_message_window_size
  401.   def adjust_message_window_size
  402.     start_name_window if @event_pop_id
  403.     return if @event_pop_id
  404.     yse_pop_message_adjust_message_window_size
  405.   end
  406.   end
  407.  
  408.   #--------------------------------------------------------------------------
  409.   # new method: adjust_pop_message
  410.   #--------------------------------------------------------------------------
  411.   def adjust_pop_message(text = " ")
  412.     return unless SceneManager.scene_is?(Scene_Map)
  413.     unless @event_pop_id
  414.       if $imported["YEA-MessageSystem"]
  415.         #adjust_message_window_size
  416.       end
  417.       return
  418.     end
  419.     n_line = cal_number_line(text)
  420.     n_line = YSE::POP_MESSAGE::LIMIT[:limit_line] if YSE::POP_MESSAGE::LIMIT[:limit_line] > 0 && cal_number_line(text) > YSE::POP_MESSAGE::LIMIT[:limit_line]
  421.     @real_lines = n_line
  422.     self.height = fitting_height(n_line)
  423.     self.width = cal_width_line(text) + 24  #<- 增加这个数字来调整后面的距离(如果不顺眼)
  424.     self.width += new_line_x
  425.     if self.width > YSE::POP_MESSAGE::LIMIT[:limit_width] && YSE::POP_MESSAGE::LIMIT[:limit_width] > 0
  426.       self.width = YSE::POP_MESSAGE::LIMIT[:limit_width]
  427.     end
  428.     create_contents
  429.     update_placement
  430.   end
  431.  
  432.   #--------------------------------------------------------------------------
  433.   # overwrite method: new_line_x
  434.   #--------------------------------------------------------------------------
  435.   def new_line_x
  436.     if $game_message.face_name.empty?
  437.       return 0
  438.     else
  439.       result = YSE::POP_MESSAGE::POSITION[:face_x_buffer]
  440.       p_x = $imported["YEA-MessageSystem"] ? YEA::MESSAGE::FACE_INDENT_X : 112
  441.       result += p_x
  442.       return result
  443.     end
  444.   end
  445.  
  446.   #--------------------------------------------------------------------------
  447.   # new method: real_lines
  448.   #--------------------------------------------------------------------------
  449.   def real_lines
  450.     @real_lines
  451.   end
  452.  
  453. end # Window_Message
  454. #==============================================================================
  455. # ¡ Scene_Map
  456. #==============================================================================
  457.  
  458. class Scene_Map < Scene_Base
  459.  
  460.   #--------------------------------------------------------------------------
  461.   # alias method: create_message_window
  462.   #--------------------------------------------------------------------------
  463.   alias yse_pm_create_message_window create_message_window
  464.   def create_message_window
  465.     yse_pm_create_message_window
  466.     @face_window = Window_Message_Face.new
  467.     @face_window.message_window = @message_window
  468.     if YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  469.       @bubble_tag_sprite = Sprite.new
  470.       @bubble_tag_sprite.visible = false
  471.       @bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT[:bubble_tag_name])
  472.       @bubble_tag_sprite.src_rect.set(0, 0, @bubble_tag_sprite.width, @bubble_tag_sprite.height / 2)
  473.       @message_window.bubble_tag = @bubble_tag_sprite
  474.     end
  475.     @message_window.face_window = @face_window
  476.   end
  477.  
  478.   #--------------------------------------------------------------------------
  479.   # alias method: dispose_spriteset
  480.   #--------------------------------------------------------------------------
  481.   alias pop_message_dispose_spriteset dispose_spriteset
  482.   def dispose_spriteset
  483.     pop_message_dispose_spriteset
  484.     return unless @bubble_tag_sprite
  485.     @bubble_tag_sprite.dispose
  486.   end
  487.  
  488. end # Scene_Map
  489.  
  490. #==============================================================================
  491. #
  492. # ¥ End of File
  493. #
  494. #==============================================================================

Lv4.逐梦者 (版主)

无限の剣制

梦石
0
星屑
10074
在线时间
5020 小时
注册时间
2013-2-28
帖子
5030

开拓者贵宾

2
发表于 2018-10-11 14:25:56 | 只看该作者
本帖最后由 VIPArcher 于 2018-10-11 14:27 编辑

我猜测你可能是需要在公共事件里调用在本事件上弹对话框。
提供个在不改动脚本的情况下你可以这样做
◆ 变量操作-脚本 变量【1】 = get_character(0).id
◆ 显示对话 \bm[\v[1]] 在本事件上弹个对话框

如果是就在事件里面写,你完全可以看到事件ID自己写
\bm[这个事件的ID] 在这个事件上弹个对话框

点评

跟我想得一样,我也是想了好久才想起来的,结果你也是这样~谢谢了  发表于 2018-10-12 12:43
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-17 00:48

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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