查看: 2764|回复: 2

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

[复制链接]
梦石
0
星屑
2019
在线时间
940 小时
注册时间
2015-10-26
回帖
293

开拓者

发表于 2018-10-10 09:15:39 | 显示全部楼层 |阅读模式

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

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

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

脚本如下

  1. #==============================================================================
  2. #
  3. # ¥ Yami Engine Ace - Pop Message
  4. # -- Last Updated: 2012.06.07
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YSE-PopMessage"] = true
  11. #==============================================================================
  12. # ¥ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.06.07 - Fixed Compatible: YEA - Ace Message System.
  15. # 2012.05.11 - Fixed Message Position.
  16. #            - Remove Requirement: YSE - Fix Events Order.
  17. # 2012.05.07 - Fixed Face position.
  18. #            - Added Requirement: YSE - Fix Events Order.
  19. # 2012.04.06 - You can change Bubble Tag filename.
  20. # 2012.03.28 - Fixed Default Message Position and Sizes.
  21. # 2012.03.27 - Fixed Default Message.
  22. # 2012.03.27 - Added Bubble Tag.
  23. # 2012.03.25 - Fixed Escape Message.
  24. # 2012.03.24 - Fixed Battle Message.
  25. # 2012.03.24 - Rewrote script.
  26. #
  27. #==============================================================================
  28. # ¥ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save.
  32. #
  33. # -----------------------------------------------------------------------------
  34. # Message Window text Codes - These go inside of your message window.
  35. # -----------------------------------------------------------------------------
  36. #  Position:   Effect:
  37. #    \bm[x]    - Sets Message Window position to event x. *Note
  38. #    \cbm      - Cancel bubble message.
  39. #
  40. #              *Note: Set to 0 to sets position to Game Player.
  41. #
  42. #==============================================================================
  43. # ¥ Compatibility
  44. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  45. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  46. # it will run with RPG Maker VX without adjusting.
  47. #
  48. #==============================================================================

  49. module YSE
  50.   module POP_MESSAGE

  51.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  52.     # - Visual Settings -
  53.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  54.     LIMIT = { # Start.
  55.       :limit_width    =>  0,  # Set to 0 to disable limit.
  56.       :limit_line     =>  6,  # Set to 0 to disable limit.
  57.     } # End.

  58.     POSITION = { # Start.
  59.       :x_buffer       =>  0,
  60.       :y_buffer       =>  -36,
  61.       :face_x_buffer  =>  8,
  62.       :face_y_buffer  =>  24,
  63.       :tag_y_buffer   =>  -6,
  64.       :name_x_buffer  =>  112, # Require YEA - Message System.
  65.     } # End.

  66.     EFFECT = { # Start.
  67.       :fade_face       =>  true,
  68.       :move_face       =>  true,
  69.       :use_bubble_tag  =>  true,
  70.       :bubble_tag_name => "BubbleTag",
  71.     } # End.

  72.   end
  73. end

  74. #==============================================================================
  75. # ¥ Editting anything past this point may potentially result in causing
  76. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  77. # halitosis so edit at your own risk.
  78. #==============================================================================

  79. #==============================================================================
  80. # ¡ Spriteset_Map
  81. #==============================================================================

  82. class Spriteset_Map

  83.   #--------------------------------------------------------------------------
  84.   # public instance variables
  85.   #--------------------------------------------------------------------------
  86.   attr_accessor :character_sprites

  87. end # Spriteset_Map

  88. #==============================================================================
  89. # ¡ Window_Message_Face
  90. #==============================================================================

  91. class Window_Message_Face < Window_Base

  92.   #--------------------------------------------------------------------------
  93.   # initialize
  94.   #--------------------------------------------------------------------------
  95.   def initialize
  96.     super(0, 0, 120, 120)
  97.     self.opacity = 0
  98.     @face_name = ""
  99.     @face_index = 0
  100.     @move_x = 0
  101.     close
  102.   end

  103.   #--------------------------------------------------------------------------
  104.   # message_window=
  105.   #--------------------------------------------------------------------------
  106.   def message_window=(window)
  107.     @message_window = window
  108.   end

  109.   #--------------------------------------------------------------------------
  110.   # set_face
  111.   #--------------------------------------------------------------------------
  112.   def set_face
  113.     contents.clear
  114.     return unless @message_window
  115.     if !$game_message.face_name.empty?
  116.       draw_face($game_message.face_name, $game_message.face_index, 0, 0)
  117.       set_position
  118.       show_face
  119.     else
  120.       hide_face
  121.     end
  122.   end

  123.   #--------------------------------------------------------------------------
  124.   # set_position
  125.   #--------------------------------------------------------------------------
  126.   def set_position
  127.     return unless @message_window
  128.     self.x = @message_window.x
  129.     self.y = @message_window.y - 96
  130.     self.x += YSE::POP_MESSAGE::POSITION[:face_x_buffer]
  131.     self.y += YSE::POP_MESSAGE::POSITION[:face_y_buffer]
  132.     self.y += (@message_window.real_lines - 1) * 30
  133.     self.z = @message_window.z + 1
  134.     if (@face_name != $game_message.face_name || @face_index != $game_message.face_index)
  135.       if YSE::POP_MESSAGE::EFFECT[:move_face]
  136.         @move_x = 30
  137.         self.x -= 30
  138.       end
  139.       @face_name = $game_message.face_name
  140.       @face_index = $game_message.face_index
  141.       self.contents_opacity = 0 if YSE::POP_MESSAGE::EFFECT[:fade_face]
  142.     end
  143.   end

  144.   #--------------------------------------------------------------------------
  145.   # show_face
  146.   #--------------------------------------------------------------------------
  147.   def show_face
  148.     open
  149.   end

  150.   #--------------------------------------------------------------------------
  151.   # hide_face
  152.   #--------------------------------------------------------------------------
  153.   def hide_face
  154.     contents.clear
  155.     close
  156.   end

  157.   #--------------------------------------------------------------------------
  158.   # update
  159.   #--------------------------------------------------------------------------
  160.   def update
  161.     super
  162.     self.contents_opacity += 15 if self.contents_opacity < 255
  163.     unless @move_x <= 0
  164.       self.x += 2
  165.       @move_x -= 2
  166.     end
  167.   end

  168. end # Sprite_Message_Face

  169. #==============================================================================
  170. # ¡ Window_Message
  171. #==============================================================================

  172. class Window_Message < Window_Base

  173.   #--------------------------------------------------------------------------
  174.   # new method: face_window=
  175.   #--------------------------------------------------------------------------
  176.   def face_window=(window)
  177.     @face_window = window
  178.   end

  179.   #--------------------------------------------------------------------------
  180.   # new method: bubble_tag=
  181.   #--------------------------------------------------------------------------
  182.   def bubble_tag=(sprite)
  183.     @bubble_tag = sprite
  184.   end

  185.   #--------------------------------------------------------------------------
  186.   # new method: message_escape_characters_pop_message
  187.   #--------------------------------------------------------------------------
  188.   def message_escape_characters_pop_message(result)
  189.     result.gsub!(/\eBM\[(\d+)\]/i) { event_pop_message_setup($1.to_i, false) }
  190.     result.gsub!(/\eBMF\[(\d+)\]/i) { event_pop_message_setup($1.to_i, true) }
  191.     result.gsub!(/\eCBM/i) { event_pop_message_setup(nil, false) }
  192.     result
  193.   end

  194.   #--------------------------------------------------------------------------
  195.   # alias method: convert_escape_characters
  196.   #--------------------------------------------------------------------------
  197.   alias yse_convert_escape_characters_pm convert_escape_characters
  198.   def convert_escape_characters(text)
  199.     result = yse_convert_escape_characters_pm(text)
  200.     result = message_escape_characters_pop_message(result)
  201.     result
  202.   end

  203.   #--------------------------------------------------------------------------
  204.   # new method: event_pop_message_setup
  205.   #--------------------------------------------------------------------------
  206.   def event_pop_message_setup(event_id, follower = false)
  207.     if follower && $game_player.followers[event_id].nil?
  208.       @event_pop_id = nil
  209.       @event_pop_follower = false
  210.       return ""
  211.     end
  212.     @event_pop_follower = follower
  213.     @event_pop_id = event_id
  214.     return ""
  215.   end

  216.   #--------------------------------------------------------------------------
  217.   # new method: set_face_position
  218.   #--------------------------------------------------------------------------
  219.   def set_face_position
  220.     return unless SceneManager.scene_is?(Scene_Map)
  221.     return unless @event_pop_id
  222.     return unless @face_window
  223.     contents.clear
  224.     @face_window.set_face
  225.     return unless $imported["YEA-MessageSystem"]
  226.     return if @face_window.close?
  227.     #@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)
  228.   end

  229.   #--------------------------------------------------------------------------
  230.   # alias method: new_page
  231.   #--------------------------------------------------------------------------
  232.   alias window_message_new_page_pm_yse new_page
  233.   def new_page(text, pos)
  234.     window_message_new_page_pm_yse(text, pos)
  235.     set_face_position
  236.   end

  237.   #--------------------------------------------------------------------------
  238.   # alias method: close
  239.   #--------------------------------------------------------------------------
  240.   alias pop_message_close close
  241.   def close
  242.     pop_message_close
  243.     return unless SceneManager.scene_is?(Scene_Map)
  244.     return unless @event_pop_id
  245.     @event_pop_id = nil
  246.     @event_pop_follower = false
  247.     @face_window.hide_face
  248.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  249.     @bubble_tag.visible = false if @bubble_tag
  250.   end

  251.   #--------------------------------------------------------------------------
  252.   # alias method: open_and_wait
  253.   #--------------------------------------------------------------------------
  254.   alias pop_message_open_and_wait open_and_wait
  255.   def open_and_wait
  256.     pop_message_open_and_wait
  257.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  258.     @bubble_tag.visible = true if @event_pop_id && @bubble_tag
  259.   end

  260.   #--------------------------------------------------------------------------
  261.   # alias method: process_all_text
  262.   #--------------------------------------------------------------------------
  263.   alias pop_message_process_all_text process_all_text
  264.   def process_all_text
  265.     @event_pop_id = nil
  266.     convert_escape_characters($game_message.all_text)
  267.     update_placement
  268.     adjust_pop_message($game_message.all_text)
  269.     pop_message_process_all_text
  270.   end

  271.   #--------------------------------------------------------------------------
  272.   # alias method: update_placement
  273.   #--------------------------------------------------------------------------
  274.   alias event_pop_message_update_placement update_placement
  275.   def update_placement
  276.     if SceneManager.scene_is?(Scene_Map)
  277.       if @event_pop_id.nil?
  278.         fix_default_message
  279.         event_pop_message_update_placement
  280.       elsif @event_pop_id == 0
  281.         character = $game_player
  282.         self.y = character.screen_y - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  283.         self.x = character.screen_x - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  284.         fix_position_bubble(character)
  285.         set_bubble_tag(character)
  286.       elsif @event_pop_id > 0
  287.         hash = @event_pop_follower ? $game_player.followers : $game_map.events
  288.         character = hash[@event_pop_id]
  289.         self.y = character.screen_y - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  290.         self.x = character.screen_x - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  291.         fix_position_bubble(character)
  292.         set_bubble_tag(character)
  293.       end
  294.     else
  295.       event_pop_message_update_placement
  296.     end
  297.   end

  298.   #--------------------------------------------------------------------------
  299.   # new method: fix_default_message
  300.   #--------------------------------------------------------------------------
  301.   def fix_default_message
  302.     self.width = window_width
  303.     self.height = window_height
  304.     self.x = 0
  305.     @face_window.hide_face if @face_window
  306.     create_contents
  307.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  308.     @bubble_tag.visible = false if @bubble_tag
  309.   end

  310.   #--------------------------------------------------------------------------
  311.   # new method: fix_position_bubble
  312.   #--------------------------------------------------------------------------
  313.   def fix_position_bubble(character)
  314.     end_x = self.x + self.width
  315.     end_y = self.y + self.height
  316.     self.x = 0 if self.x < 0
  317.     self.y = character.screen_y if self.y < 0
  318.     self.x = Graphics.width - self.width if end_x > Graphics.width
  319.     self.y = Graphics.height - self.height if end_y > Graphics.height
  320.   end

  321.   #--------------------------------------------------------------------------
  322.   # new method: set_bubble_tag
  323.   #--------------------------------------------------------------------------
  324.   def set_bubble_tag(character)
  325.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  326.     return unless @bubble_tag
  327.     up = self.y == character.screen_y
  328.     self.y += up ? @bubble_tag.height / 2 : [email]-@bubble_tag.height[/email] / 2
  329.     @bubble_tag.x = character.screen_x - @bubble_tag.width / 2
  330.     if up
  331.       @bubble_tag.src_rect.set(0, @bubble_tag.height, @bubble_tag.width, @bubble_tag.height)
  332.       @bubble_tag.y = self.y - @bubble_tag.height - YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  333.     else
  334.       @bubble_tag.src_rect.set(0, 0, @bubble_tag.width, @bubble_tag.height)
  335.       @bubble_tag.y = self.y + self.height + YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  336.     end
  337.   end

  338.   #--------------------------------------------------------------------------
  339.   # new method: cal_number_line
  340.   #--------------------------------------------------------------------------
  341.   def cal_number_line(text)
  342.     result = 0
  343.     text.each_line { result += 1 }
  344.     return result
  345.   end

  346.   #--------------------------------------------------------------------------
  347.   # new method: cal_width_line
  348.   #--------------------------------------------------------------------------
  349.   def cal_width_line(text)
  350.     result = 0
  351.     text.each_line { |line|
  352.       result = text_size(line).width if result < text_size(line).width
  353.     }
  354.     return result
  355.   end

  356.   #--------------------------------------------------------------------------
  357.   # alias method: adjust_message_window_size
  358.   #--------------------------------------------------------------------------
  359.   if $imported["YEA-MessageSystem"]
  360.   alias yse_pop_message_adjust_message_window_size adjust_message_window_size
  361.   def adjust_message_window_size
  362.     start_name_window if @event_pop_id
  363.     return if @event_pop_id
  364.     yse_pop_message_adjust_message_window_size
  365.   end
  366.   end

  367.   #--------------------------------------------------------------------------
  368.   # new method: adjust_pop_message
  369.   #--------------------------------------------------------------------------
  370.   def adjust_pop_message(text = " ")
  371.     return unless SceneManager.scene_is?(Scene_Map)
  372.     unless @event_pop_id
  373.       if $imported["YEA-MessageSystem"]
  374.         #adjust_message_window_size
  375.       end
  376.       return
  377.     end
  378.     n_line = cal_number_line(text)
  379.     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]
  380.     @real_lines = n_line
  381.     self.height = fitting_height(n_line)
  382.     self.width = cal_width_line(text) + 24  #<- 增加这个数字来调整后面的距离(如果不顺眼)
  383.     self.width += new_line_x
  384.     if self.width > YSE::POP_MESSAGE::LIMIT[:limit_width] && YSE::POP_MESSAGE::LIMIT[:limit_width] > 0
  385.       self.width = YSE::POP_MESSAGE::LIMIT[:limit_width]
  386.     end
  387.     create_contents
  388.     update_placement
  389.   end

  390.   #--------------------------------------------------------------------------
  391.   # overwrite method: new_line_x
  392.   #--------------------------------------------------------------------------
  393.   def new_line_x
  394.     if $game_message.face_name.empty?
  395.       return 0
  396.     else
  397.       result = YSE::POP_MESSAGE::POSITION[:face_x_buffer]
  398.       p_x = $imported["YEA-MessageSystem"] ? YEA::MESSAGE::FACE_INDENT_X : 112
  399.       result += p_x
  400.       return result
  401.     end
  402.   end

  403.   #--------------------------------------------------------------------------
  404.   # new method: real_lines
  405.   #--------------------------------------------------------------------------
  406.   def real_lines
  407.     @real_lines
  408.   end

  409. end # Window_Message
  410. #==============================================================================
  411. # ¡ Scene_Map
  412. #==============================================================================

  413. class Scene_Map < Scene_Base

  414.   #--------------------------------------------------------------------------
  415.   # alias method: create_message_window
  416.   #--------------------------------------------------------------------------
  417.   alias yse_pm_create_message_window create_message_window
  418.   def create_message_window
  419.     yse_pm_create_message_window
  420.     @face_window = Window_Message_Face.new
  421.     @face_window.message_window = @message_window
  422.     if YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  423.       @bubble_tag_sprite = Sprite.new
  424.       @bubble_tag_sprite.visible = false
  425.       @bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT[:bubble_tag_name])
  426.       @bubble_tag_sprite.src_rect.set(0, 0, @bubble_tag_sprite.width, @bubble_tag_sprite.height / 2)
  427.       @message_window.bubble_tag = @bubble_tag_sprite
  428.     end
  429.     @message_window.face_window = @face_window
  430.   end

  431.   #--------------------------------------------------------------------------
  432.   # alias method: dispose_spriteset
  433.   #--------------------------------------------------------------------------
  434.   alias pop_message_dispose_spriteset dispose_spriteset
  435.   def dispose_spriteset
  436.     pop_message_dispose_spriteset
  437.     return unless @bubble_tag_sprite
  438.     @bubble_tag_sprite.dispose
  439.   end

  440. end # Scene_Map

  441. #==============================================================================
  442. #
  443. # ¥ End of File
  444. #
  445. #==============================================================================
复制代码

无限の剣制

梦石
0
星屑
10460
在线时间
5019 小时
注册时间
2013-2-28
回帖
4942

开拓者贵宾

发表于 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
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部