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

Project1

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

[已经过期] khas messgae system(以及关于quack的气泡增强脚本)

[复制链接]

Lv4.逐梦者

梦石
0
星屑
9310
在线时间
1255 小时
注册时间
2017-9-27
帖子
149
跳转到指定楼层
1
发表于 2019-3-25 22:42:25 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
khas messgae system似乎无法打出中文名字和快进对话,如下图
[img][/img]

想请问如何增加快进功能和打出中文名字

以及关于quack的增强气泡脚本...原帖 https://rpg.blue/thread-405406-1-1.html里面
之前试了这个脚本,结果477报错,搜索了一下后发现也有人反应477报错...想请问该如何修复...

RUBY 代码复制
  1. #-------------------------------------------------------------------------------
  2. # * [ACE] Khas Message System
  3. #-------------------------------------------------------------------------------
  4. # * By Nilo K. (Khas)
  5. # * Version: 1.1
  6. # * Released on: 04.23.2017
  7. #
  8. # * Social Media
  9. # Blog: arcthunder.blogspot.com
  10. # Facebook: facebook.com/khasarc
  11. # Twitter: twitter.com/arcthunder
  12. # Youtube: youtube.com/c/khasarc
  13. #
  14. # * Khas Scripts @ RPG Maker Web forums (official support!)
  15. # forums.rpgmakerweb.com/index.php?/forum/132-khas-scripts
  16. #
  17. #-------------------------------------------------------------------------------
  18. # * Terms of Use
  19. #-------------------------------------------------------------------------------
  20. # When using KHAS MESSAGE SYSTEM (the script), you agree with the following terms:
  21. # 1. If you purchased a license to one of my scripts, credit is not required.
  22. #    Otherwise, you must give credit to Khas (if you want, a link to my blog is
  23. #    always appreciated);
  24. # 2. You can use the script for free in both non-commercial and commercial
  25. #    projects;
  26. # 4. You can edit the script for using in your own project. However, you are
  27. #    not allowed to share/distribute any modified version;
  28. # 5. If you want to share a Khas script, don’t post the direct download link,
  29. #    redirect the user to my blog instead;
  30. # 6. The script can not be ported to any RPG Maker version than VX Ace.
  31. #
  32. #-------------------------------------------------------------------------------
  33. # * Instructions
  34. #-------------------------------------------------------------------------------
  35. # This script changes the original message system design and adds some new
  36. # commands that can be used when displaying messages. Below you will find a
  37. # list of these commands.
  38. #
  39. # Due to the unique design of this script, it's  recommended to think carefully
  40. # about the windowskin that you will use (it's used for menus and choices).
  41. #
  42. # The Khas Message System is plug'n'play, you will need to import to your
  43. # project only the voice SE files of the actors.
  44. #
  45. #-------------------------------------------------------------------------------
  46. # * Commands
  47. #-------------------------------------------------------------------------------
  48. # EXISTING COMMANDS
  49. # \v[x] Variable X (int)
  50. # \n[x] Actor X name (int)
  51. # \p[x] Party member X name (int)
  52. # \i[x] Draw icon X (int)
  53. # \g    Currency unit
  54. # \{    Increase text size
  55. # \}    Decrease text size
  56. # \$    Open money window
  57. # \.    Pause (1/4 second)
  58. # \|    Pause (1 second)
  59. # \!    Wait for button
  60. # \>    Instantly display (line)
  61. # \<    Cancel above
  62. # \^    Do not wait for next page
  63. # \\    Backslash
  64. #
  65. # NEW COMMANDS
  66. # \c[color] Change text color (can be an hex color like #ffffff or
  67. #           a color declared on the configuration part. Examples:
  68. #           \c[#00ff00]
  69. #           \c[green]
  70. #
  71. # \a[actor] Change the actor who's speaking. The actor must be declared
  72. #           on the configuration part. Examples:
  73. #           \a[Alice]
  74. #           \c[Ernest]
  75. #
  76. # \s[time]  Shake the screen/balloon by the given time (in frames).
  77. #           Example:
  78. #           \s[20]
  79. #
  80. # \e[x]     Place the balloon over the event X.
  81. #           Example:
  82. #           \e[12]
  83. #
  84. # \p        Place the balloon over the player.
  85. #
  86. # \f        Make the balloon float (useful for a narrator).
  87. #
  88. # \t[se]    Change the typing sound to the given sound effect.
  89. #           Example:
  90. #           \t[female]
  91. #
  92. # \x[se]    Play the given sound effect.
  93. #           Example:
  94. #           \x[Cat]
  95. #
  96. #-------------------------------------------------------------------------------
  97. # * Message Core (configuration)
  98. #-------------------------------------------------------------------------------
  99.  
  100. module Message_Core
  101.  
  102.   # ACTORS
  103.   # Declare your actors here, using the following format:
  104.   # "Actor Name" => ["color", "voice"]
  105.   # Actor Name: the actor name to be used with \a[Actor Name]
  106.   # color: the color name declared below
  107.   # voice: the voice file inside Audio/SE
  108.   Actors = {
  109.     "Eric" => ["blue", "male"],
  110.     "Natalie" => ["pink", "female"],
  111.     "Terence" => ["yellow", "male"],
  112.     "Ernest" => ["darkorange", "male"],
  113.     "Ryoma" => ["teal", "male"],
  114.     "Brenda" => ["gray", "female"],
  115.     "Rick" => ["green", "male"],
  116.     "Alice" => ["purple", "female"],
  117.     "Isabelle" => ["purple", "female"],
  118.     "Noah" => ["darkred", "male"],
  119.     "Old Man" => ["gray", "male"],
  120.     "Old Lady" => ["gray", "male"],
  121.     "Monster" => ["darkred", "male"],
  122.     "Boy" => ["blue", "male"],
  123.     "Girl" => ["pink", "female"],
  124.     "Lady" => ["purple", "female"],
  125.     "Man" => ["green", "male"],
  126.   }
  127.  
  128.   # COLORS
  129.   # Declare your colors here, using the following format:
  130.   # "colorname" => Color.new(R, G, B),
  131.   # The colorname can be used with \c[colorname]
  132.   Colors = {
  133.     "white" => Color.new(255, 255, 255),
  134.     "black" => Color.new(0, 0, 0),
  135.     "orange" => Color.new(255, 144, 9),
  136.  
  137.     "blue" => Color.new(111, 147, 191),
  138.     "pink" => Color.new(189, 74, 99),
  139.     "yellow" => Color.new(222, 164, 86),
  140.     "darkorange" => Color.new(171, 86, 36),
  141.     "teal" => Color.new(39, 89, 97),
  142.     "darkred" => Color.new(171, 61, 86),
  143.     "purple" => Color.new(121, 83, 145),
  144.     "green" => Color.new(92, 154, 75),
  145.     "gray" => Color.new(135, 156, 176),
  146.   }
  147.  
  148.   # MESSAGE BALLOON CONFIGURATION
  149.   # Background color
  150.   Background = Color.new(0,0,0,180)
  151.  
  152.   # Outline color
  153.   Outline = Color.new(255,255,255,120)
  154.  
  155.   # Minimum width
  156.   Minimum_Width = 80
  157.  
  158.   # Font properties
  159.   Font_Name = "Arial"
  160.   Font_Size = 18
  161.   Font_Bold = true
  162.   Font_Italic = false
  163.   Font_Outline = false
  164.  
  165.   # SE VOLUME
  166.   # Volume used to play voices
  167.   SE_Volume = 80
  168.  
  169.   # PAUSE CYCLE
  170.   # Number of frames to blink the cursor
  171.   Pause_Cycle = 30
  172.  
  173.   # Change these only if you're having trouble with your font
  174.   Standard_Padding = 4
  175.   New_Line_X = 4 + Standard_Padding
  176.   New_Page_Y = 3
  177.  
  178. end
  179.  
  180. #-------------------------------------------------------------------------------
  181. # * Default Font
  182. #-------------------------------------------------------------------------------
  183.  
  184. Font.default_name = [Message_Core::Font_Name]
  185. Font.default_size = Message_Core::Font_Size
  186. Font.default_bold = Message_Core::Font_Bold
  187. Font.default_outline = Message_Core::Font_Outline
  188. Font.default_italic = Message_Core::Font_Italic
  189.  
  190. #-------------------------------------------------------------------------------
  191. # * Sprite Message
  192. #-------------------------------------------------------------------------------
  193.  
  194. class Sprite_Message < Sprite
  195.  
  196.   include Message_Core
  197.  
  198.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  199.   # * Initialize (Executed once)
  200.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  201.  
  202.   def initialize
  203.     super(nil)
  204.     initialize_sprite
  205.     initialize_pause
  206.     create_all_windows
  207.     clear_instance_variables
  208.   end
  209.  
  210.   def initialize_sprite
  211.     self.bitmap = Bitmap.new(1,1)
  212.     self.opacity = 0
  213.     self.visible = false
  214.     self.z = 200
  215.   end
  216.  
  217.   def initialize_pause
  218.     @pause_sprite = Sprite.new
  219.     @pause_sprite.bitmap = Bitmap.new(3,3)
  220.     @pause_sprite.bitmap.fill_rect(0,0,3,3,Colors["white"])
  221.     @pause_sprite.visible = false
  222.     @pause_sprite.z = self.z + 1
  223.   end
  224.  
  225.   def create_all_windows
  226.     @gold_window = Window_Gold.new
  227.     @gold_window.x = Graphics.width - @gold_window.width
  228.     @gold_window.y = 0
  229.     @gold_window.openness = 0
  230.     @choice_window = Window_ChoiceList.new(self)
  231.     @number_window = Window_NumberInput.new(self)
  232.     @item_window = Window_KeyItem.new(self)
  233.   end
  234.  
  235.   def clear_instance_variables
  236.     @fiber = nil
  237.     @opening = false
  238.     @closing = false
  239.     @pause = false
  240.     clear_flags
  241.   end
  242.  
  243.  
  244.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  245.   # * Dispose (Executed once)
  246.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  247.  
  248.   def dispose
  249.     dispose_all_windows
  250.     dispose_pause
  251.     dispose_bitmap
  252.     super
  253.   end
  254.  
  255.   def dispose_all_windows
  256.     @gold_window.dispose
  257.     @choice_window.dispose
  258.     @number_window.dispose
  259.     @item_window.dispose
  260.   end
  261.  
  262.   def dispose_bitmap
  263.     self.bitmap.dispose if self.bitmap
  264.   end
  265.  
  266.   def dispose_pause
  267.     @pause_sprite.bitmap.dispose
  268.     @pause_sprite.dispose
  269.   end
  270.  
  271.  
  272.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  273.   # * Update
  274.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  275.  
  276.   def update
  277.     update_effects
  278.     update_all_windows
  279.     update_fiber
  280.   end
  281.  
  282.   def update_effects
  283.     update_open if @opening
  284.     update_close if @closing
  285.     update_pause if @pause
  286.     update_shake if @shake > 0
  287.   end
  288.  
  289.   def update_all_windows
  290.     @gold_window.update
  291.     @choice_window.update
  292.     @number_window.update
  293.     @item_window.update
  294.   end
  295.  
  296.   def update_fiber
  297.     if @fiber
  298.       @fiber.resume
  299.     elsif $game_message.busy? && !$game_message.scroll_mode
  300.       @fiber = Fiber.new { fiber_main }
  301.       @fiber.resume
  302.     else
  303.       $game_message.visible = false
  304.     end
  305.   end
  306.  
  307.   def update_open
  308.     self.opacity += 32
  309.     @opening = (self.opacity < 255)
  310.   end
  311.  
  312.   def update_close
  313.     self.opacity -= 32
  314.     @closing = (self.opacity > 0)
  315.   end
  316.  
  317.   def update_pause
  318.     if @pause_timer > 0
  319.       @pause_timer -= 1
  320.     else
  321.       @pause_sprite.visible = !@pause_sprite.visible
  322.       @pause_timer = Pause_Cycle
  323.     end
  324.   end
  325.  
  326.   def update_shake
  327.     if @shake > 1
  328.       self.ox = rand(17) - 8
  329.       self.oy = rand(17) - 8
  330.       @shake -= 1
  331.     else
  332.       stop_shake
  333.     end
  334.   end
  335.  
  336.  
  337.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  338.   # * Effect Control
  339.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  340.  
  341.   def open_and_wait
  342.     @opening = true
  343.     Fiber.yield while @opening
  344.   end
  345.  
  346.   def close_and_wait
  347.     @closing = true
  348.     Fiber.yield until all_close?
  349.   end
  350.  
  351.   def show_pause
  352.     @pause_sprite.visible = true
  353.     @pause = true
  354.     @pause_timer = Pause_Cycle
  355.   end
  356.  
  357.   def hide_pause
  358.     @pause_sprite.visible = false
  359.     @pause = false
  360.   end
  361.  
  362.   def shake(duration)
  363.     @shake = duration
  364.   end
  365.  
  366.   def stop_shake
  367.     self.ox = 0
  368.     self.oy = 0
  369.     @shake = 0
  370.   end
  371.  
  372.  
  373.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  374.   # * Main Processing
  375.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  376.  
  377.   def fiber_main
  378.     $game_message.visible = true
  379.     self.visible = true
  380.     loop do
  381.       process_all_text if $game_message.has_text?
  382.       process_input
  383.       $game_message.clear
  384.       @gold_window.close
  385.       Fiber.yield
  386.       break unless text_continue?
  387.     end
  388.     close_and_wait
  389.     clear_balloon
  390.     self.visible = false
  391.     $game_message.visible = false
  392.     @fiber = nil
  393.   end
  394.  
  395.  
  396.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  397.   # * Drawing processes
  398.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  399.  
  400.   def draw_balloon
  401.     # Reset stuff for new balloon
  402.     reset_font_settings
  403.     reset_character_actor
  404.  
  405.     # Process text
  406.     text = convert_escape_characters($game_message.all_text)
  407.     scan_special_commands(text)
  408.     text = remove_escape_characters(text)
  409.  
  410.     # Should the balloon float?
  411.     @float = true if @character.nil?
  412.  
  413.     # Check if the balloon will have a namebox
  414.     @namebox_yplus = (@actor ? text_size(@actor).height : 0)
  415.     @voice = (@actor ? Actors[@actor][1] : nil)
  416.  
  417.     # Check if the balloon will have a detail
  418.     @detail_yplus = (@float ? 0 : 10)
  419.  
  420.     # Calculate text dimensions
  421.     tw = fitting_width(text)
  422.     th = fitting_height(text) + @namebox_yplus + @detail_yplus
  423.  
  424.     # Check if the balloon needs to be inverted
  425.     if invert_balloon?(th)
  426.       @inverted = true
  427.       @margin_top = @detail_yplus
  428.       @margin_bottom = @namebox_yplus
  429.     else
  430.       @inverted = false
  431.       @margin_top = @namebox_yplus
  432.       @margin_bottom = @detail_yplus
  433.     end
  434.  
  435.     # Calculate balloon dimensions
  436.     balloon = Rect.new
  437.     balloon.x = 0
  438.     balloon.y = @margin_top
  439.     balloon.width = tw > Minimum_Width ? tw : Minimum_Width
  440.     balloon.height = th - @margin_top - @margin_bottom
  441.  
  442.     # Create a new bitmap
  443.     self.bitmap.dispose if self.bitmap
  444.     self.bitmap = Bitmap.new(balloon.width, th)
  445.     reset_font_settings
  446.  
  447.     # Draw the balloon
  448.     self.bitmap.fill_rect(balloon.x, balloon.y, balloon.width, balloon.height, Outline)
  449.     self.bitmap.fill_rect(balloon.x+1, balloon.y+1, balloon.width-2, balloon.height-2, Background)
  450.  
  451.     # Draw the namebox
  452.     draw_namebox(@inverted ? (th - @namebox_yplus - 2) : 0) if @actor
  453.   end
  454.  
  455.   def clear_balloon
  456.     self.bitmap.clear
  457.   end
  458.  
  459.   def draw_namebox(y)
  460.     rect = text_size(@actor)
  461.     color = Colors[Actors[@actor][0]]
  462.     color.alpha = Background.alpha
  463.     self.bitmap.fill_rect(4,y,rect.width+10,rect.height+2,Outline)
  464.     self.bitmap.fill_rect(5,y+1,rect.width+8,rect.height,color)
  465.     self.bitmap.draw_text(9,y+1,rect.width,rect.height,@actor)
  466.   end
  467.  
  468.   def draw_detail(x, y, reverse, upside_down)
  469.     dx = (reverse ? 1 : 0)
  470.     dy = (upside_down ? -1 : 1)
  471.     x -= 12 if reverse
  472.     for i in 12.downto(2)
  473.       fill_line(x, y, i)
  474.       x += dx
  475.       y += dy
  476.     end
  477.   end
  478.  
  479.   def fill_rect(x, y, sx, sy)
  480.     self.bitmap.fill_rect(x, y, sx, sy, Outline)
  481.     self.bitmap.fill_rect(x+1, y+1, sx-2, sy-2, Background)
  482.   end
  483.  
  484.   def fill_line(x, y, sx)
  485.     self.bitmap.fill_rect(x, y, sx, 1, Outline)
  486.     self.bitmap.fill_rect(x+1, y, sx-2, 1, Background)
  487.   end
  488.  
  489.  
  490.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  491.   # * Size/Position processing
  492.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  493.  
  494.   def move_balloon
  495.     if @float
  496.       x = (Graphics.width - width)/2
  497.       y = Graphics.height - height - self.bitmap.font.size
  498.     else
  499.       # Get the actual character and its height
  500.       bitmap = Cache.character(@character.character_name)
  501.       sign = @character.character_name[/^[\!\$]./]
  502.       if sign && sign.include?('$')
  503.         cw = bitmap.width / 6
  504.         ch = bitmap.height / 4
  505.       else
  506.         cw = bitmap.width / 24
  507.         ch = bitmap.height / 8
  508.       end
  509.  
  510.       # Calc initial position
  511.       x = @character.screen_x - width / 2
  512.       y = @character.screen_y - height - ch
  513.  
  514.       # Check if the ballon is out of the screen
  515.       x = 2 if x < 2
  516.       x = Graphics.width - width - 2 if (x + width) > (Graphics.width - 2)
  517.       y = @character.screen_y if y < 0
  518.  
  519.       # Draw the detail
  520.       reverse = @character.direction < 5
  521.       sx = @character.screen_x - x + (reverse ? -cw : cw)
  522.       if sx < 0
  523.         reverse = !reverse
  524.         sx = @character.screen_x - x + (reverse ? -cw : cw)
  525.       elsif sx > self.bitmap.width
  526.         reverse = !reverse
  527.         sx = @character.screen_x - x + (reverse ? -cw : cw)
  528.       end
  529.       sy = (@inverted ? @margin_top : (self.bitmap.height - @margin_bottom - 1))
  530.       draw_detail(sx, sy, reverse, @inverted)
  531.     end
  532.  
  533.     # Set the position
  534.     self.x = x
  535.     self.y = y
  536.  
  537.     # Set the pause sprite position
  538.     @pause_sprite.x = self.x + self.width - 6
  539.     @pause_sprite.y = self.y + self.height - @margin_bottom - 6
  540.   end
  541.  
  542.   def invert_balloon?(h)
  543.     return false if @float
  544.     bitmap = Cache.character(@character.character_name)
  545.     sign = @character.character_name[/^[\!\$]./]
  546.     char_height = bitmap.height / (sign && sign.include?('$') ? 4 : 8)
  547.     @character.screen_y - h - char_height < 0
  548.   end
  549.  
  550.   def width
  551.     self.bitmap ? self.bitmap.width : 1
  552.   end
  553.  
  554.   def height
  555.     self.bitmap ? self.bitmap.height : 1
  556.   end
  557.  
  558.   def text_width(text)
  559.     result = 0
  560.     text.each_line do |line|
  561.       lw = text_size(line).width
  562.       result = lw if lw > result
  563.     end
  564.     result
  565.   end
  566.  
  567.   def text_height(text)
  568.     result = 0
  569.     text.each_line do |line|
  570.       result += line_height(line)
  571.     end
  572.     result
  573.   end
  574.  
  575.   def line_height(text)
  576.     result = self.bitmap.font.size
  577.     last_font_size = self.bitmap.font.size
  578.     text.slice(/^.*$/).scan(/\e[\{\}]/).each do |esc|
  579.       make_font_bigger  if esc == "\e{"
  580.       make_font_smaller if esc == "\e}"
  581.       result = [result, self.bitmap.font.size].max
  582.     end
  583.     self.bitmap.font.size = last_font_size
  584.     result
  585.   end
  586.  
  587.   def fitting_height(text)
  588.     text_height(text) + Standard_Padding * 2
  589.   end
  590.  
  591.   def fitting_width(text)
  592.     text_width(text) + Standard_Padding * 2
  593.   end
  594.  
  595.  
  596.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  597.   # * Text processing
  598.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  599.  
  600.   def process_all_text
  601.     text = convert_escape_characters($game_message.all_text)
  602.     pos = {}
  603.     new_page(text, pos)
  604.     until text.empty?
  605.       Fiber.yield if @skip_frame
  606.       @skip_frame = !@skip_frame
  607.       process_character(text.slice!(0, 1), text, pos)
  608.     end
  609.   end
  610.  
  611.   def new_page(text, pos)
  612.     draw_balloon
  613.     move_balloon
  614.     open_and_wait if self.opacity < 255
  615.     pos[:x] = New_Line_X
  616.     pos[:y] = New_Page_Y + @margin_top
  617.     pos[:new_x] = New_Line_X
  618.     pos[:height] = line_height(text)
  619.     clear_flags
  620.   end
  621.  
  622.   def clear_flags
  623.     @show_fast = false
  624.     @pause_skip = false
  625.     @skip_frame = false
  626.     @sound = true
  627.     @shake = 0
  628.   end
  629.  
  630.   def text_continue?
  631.     $game_message.has_text?
  632.   end
  633.  
  634.   def update_show_fast
  635.     @show_fast = true if Input.trigger?(:C)
  636.   end
  637.  
  638.   def wait_for_one_character
  639.     update_show_fast
  640.     Fiber.yield unless @show_fast
  641.   end
  642.  
  643.   def need_new_page?(text, pos)
  644.     pos[:y] + pos[:height] > self.bitmap.height && !text.empty?
  645.   end
  646.  
  647.   def process_new_page(text, pos)
  648.     text.slice!(/^\n/)
  649.     input_pause
  650.     new_page(text, pos)
  651.   end
  652.  
  653.   def process_draw_icon(icon_index, pos)
  654.     bitmap = Cache.system("Iconset")
  655.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  656.     self.bitmap.blt(pos[:x], pos[:y], bitmap, rect)
  657.     pos[:x] += 24
  658.     wait_for_one_character
  659.   end
  660.  
  661.   def process_escape_character(code, text, pos)
  662.     case code.upcase
  663.     when '$'
  664.       @gold_window.open
  665.     when '.'
  666.       wait(15)
  667.     when '|'
  668.       wait(60)
  669.     when '!'
  670.       input_pause
  671.     when '>'
  672.       @show_fast = true
  673.     when '<'
  674.       @show_fast = false
  675.     when '^'
  676.       @pause_skip = true
  677.     when 'C'
  678.       change_color(text.slice!(/^\[#?\w+\]/)[/#?\w+/])
  679.     when 'I'
  680.       process_draw_icon(text.slice!(/^\[\d+\]/)[/\d+/].to_i, pos)
  681.     when '{'
  682.       make_font_bigger
  683.     when '}'
  684.       make_font_smaller
  685.     when 'A'
  686.       text.slice!(/^\[[\w\s]+\]/)
  687.     when 'S'
  688.       shake(text.slice!(/^\[\d+\]/)[/\d+/].to_i)
  689.     when 'E'
  690.       text.slice!(/^\[\d+\]/)
  691.     when 'T'
  692.       @voice = text.slice!(/^\[\w*\]/)[/\w*/]
  693.       @voice = nil unless @voice.size > 0
  694.     when 'X'
  695.       Audio.se_play("Audio/se/#{text.slice!(/^\[\w+\]/)[/\w+/]}", SE_Volume)
  696.     end
  697.   end
  698.  
  699.   def actor_name(n)
  700.     actor = n >= 1 ? $game_actors[n] : nil
  701.     actor ? actor.name : ""
  702.   end
  703.  
  704.   def party_member_name(n)
  705.     actor = n >= 1 ? $game_party.members[n - 1] : nil
  706.     actor ? actor.name : ""
  707.   end
  708.  
  709.   def convert_escape_characters(text)
  710.     result = text.to_s.clone
  711.     result.gsub!(/\\/)            { "\e" }
  712.     result.gsub!(/\e\e/)          { "\\" }
  713.     result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
  714.     result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
  715.     result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }
  716.     result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }
  717.     result.gsub!(/\eG/i)          { Vocab::currency_unit }
  718.     result
  719.   end
  720.  
  721.   def remove_escape_characters(text)
  722.     result = text.to_s.clone
  723.     result.gsub!(/\ec\[#?\w+\]/i,"")
  724.     result.gsub!(/\es\[\d+\]/i,"")
  725.     result.gsub!(/\ee\[\d+\]/i,"")
  726.     result.gsub!(/\ea\[[\w\s]+\]/i,"")
  727.     result.gsub!(/\et\[\w*\]/i,"")
  728.     result.gsub!(/\ex\[\w+\]/i,"")
  729.     result.gsub!(/\ep/i, "")
  730.     result.gsub!(/\ef/i, "")
  731.     result.gsub!(/\e\|/, "")
  732.     result.gsub!(/\e\./, "")
  733.     result.gsub!(/\e\</, "")
  734.     result.gsub!(/\e\>/, "")
  735.     result.gsub!(/\e\^/, "")
  736.     result
  737.   end
  738.  
  739.   def scan_special_commands(text)
  740.     if text =~ /\ep/i
  741.       @character = $game_player
  742.     end
  743.  
  744.     if text =~ /\ef/i
  745.       @float = true
  746.     end
  747.  
  748.     if text =~ /\ea\[([\w\s]+)\]/i
  749.       @actor = $1 if Actors[$1]
  750.     end
  751.  
  752.     if text =~ /\ee\[(\d+)\]/i
  753.       @character = $game_map.events[$1.to_i] if $game_map.events[$1.to_i]
  754.     end
  755.  
  756.   end
  757.  
  758.   def text_size(str)
  759.     self.bitmap.text_size(str)
  760.   end
  761.  
  762.  
  763.  
  764.   def process_character(c, text, pos)
  765.     case c
  766.     when "\n"   # New line
  767.       process_new_line(text, pos)
  768.     when "\f"   # New page
  769.       process_new_page(text, pos)
  770.     when "\e"   # Control character
  771.       process_escape_character(obtain_escape_code(text), text, pos)
  772.     else        # Normal character
  773.       process_normal_character(c, pos)
  774.     end
  775.   end
  776.  
  777.   def process_normal_character(c, pos)
  778.     char_width = text_size(c).width
  779.     self.bitmap.draw_text(pos[:x], pos[:y], char_width * 2, pos[:height], c)
  780.     pos[:x] += char_width
  781.     Audio.se_play("Audio/se/#{@voice}") if @sound && c != " " && @voice
  782.     @sound = !@sound
  783.  
  784.     wait_for_one_character
  785.   end
  786.  
  787.  
  788.   def process_new_line(text, pos)
  789.     pos[:x] = pos[:new_x]
  790.     pos[:y] += pos[:height]
  791.     pos[:height] = line_height(text)
  792.     if need_new_page?(text, pos)
  793.       input_pause
  794.       new_page(text, pos)
  795.     end
  796.   end
  797.  
  798.   def obtain_escape_code(text)
  799.     text.slice!(/^[\$\.\|\^!><\{\}\\]|^[A-Z]/i)
  800.   end
  801.  
  802.  
  803.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  804.   # * Font
  805.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  806.  
  807.   def reset_font_settings
  808.     change_color("white")
  809.     self.bitmap.font.size = Font.default_size
  810.     self.bitmap.font.bold = Font.default_bold
  811.     self.bitmap.font.italic = Font.default_italic
  812.   end
  813.  
  814.   def change_color(code)
  815.     if Colors[code]
  816.       self.bitmap.font.color.set(Colors[code])
  817.     elsif code =~ /#(..)(..)(..)/
  818.       self.bitmap.font.color.set(Color.new($1.hex, $2.hex, $3.hex))
  819.     end
  820.   end
  821.  
  822.   def make_font_bigger
  823.     self.bitmap.font.size += 8 if self.bitmap.font.size <= 64
  824.   end
  825.  
  826.   def make_font_smaller
  827.     self.bitmap.font.size -= 8 if self.bitmap.font.size >= 16
  828.   end
  829.  
  830.  
  831.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  832.   # * Input processing
  833.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  834.  
  835.   def process_input
  836.     if $game_message.choice?
  837.       input_choice
  838.     elsif $game_message.num_input?
  839.       input_number
  840.     elsif $game_message.item_choice?
  841.       input_item
  842.     else
  843.       input_pause unless @pause_skip
  844.     end
  845.   end
  846.  
  847.   def input_pause
  848.     show_pause
  849.     wait(10)
  850.     Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C)
  851.     Input.update
  852.     hide_pause
  853.   end
  854.  
  855.   def input_choice
  856.     @choice_window.start
  857.     Fiber.yield while @choice_window.active
  858.   end
  859.  
  860.   def input_number
  861.     @number_window.start
  862.     Fiber.yield while @number_window.active
  863.   end
  864.  
  865.   def input_item
  866.     @item_window.start
  867.     Fiber.yield while @item_window.active
  868.   end
  869.  
  870.  
  871.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  872.   # * Other processing
  873.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  874.  
  875.   def close?
  876.     (self.opacity == 0)
  877.   end
  878.  
  879.   def all_close?
  880.     close? && @choice_window.close? && @number_window.close? && @item_window.close?
  881.   end
  882.  
  883.   def wait(duration)
  884.     duration.times { Fiber.yield }
  885.   end
  886.  
  887.   def reset_character_actor
  888.     @float = false
  889.     @actor = nil
  890.     @character = nil
  891.     if $game_map.interpreter.event_id && $game_map.events[$game_map.interpreter.event_id]
  892.       @character = $game_map.events[$game_map.interpreter.event_id]
  893.     end
  894.   end
  895.  
  896. end
  897.  
  898. #-------------------------------------------------------------------------------
  899. # * Scene Map
  900. #-------------------------------------------------------------------------------
  901.  
  902. class Scene_Map < Scene_Base
  903.  
  904.   include Message_Core
  905.  
  906.   def create_message_window
  907.     @khas_message = Sprite_Message.new
  908.   end
  909.  
  910.   def update_all_windows
  911.     @khas_message.update
  912.     super
  913.   end
  914.  
  915.   def dispose_all_windows
  916.     @khas_message.dispose
  917.     super
  918.   end
  919.  
  920. end
  921.  
  922. #-------------------------------------------------------------------------------
  923. # * End
  924. #-------------------------------------------------------------------------------

问题.png (150.52 KB, 下载次数: 13)

问题.png
头像被屏蔽

Lv4.逐梦者 (禁止发言)

梦石
0
星屑
11783
在线时间
38 小时
注册时间
2019-3-1
帖子
22
2
发表于 2019-4-5 18:42:44 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-24 02:55

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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