Project1

标题: [向DH致敬]VA简易半身像对话框Beta [打印本页]

作者: LBQ    时间: 2013-6-30 09:01
标题: [向DH致敬]VA简易半身像对话框Beta
本帖最后由 Sion 于 2013-12-21 20:54 编辑

【向Division Heaven致敬】

好的,于是这个脚本的语句混乱、逻辑不清、bug多多、异常的蛋疼,所以这个才是beta版=-=

于是乎二话不说上范例:
Bust Shot.rar (799.54 KB, 下载次数: 3402) (没有自带rgss300.dll请自己打开范例之后保存之后使用)
RUBY 代码复制
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ 半身像对话框 by LBQ
  4. #------------------------------------------------------------------------------
  5. #  一个简单的半身像对话框罢了= =
  6. #------------------------------------------------------------------------------
  7. # ■ 用法一览
  8. #     1:如何将半身像应用到游戏中?
  9. #       ——如果想要把一个脸图替换成半身像,则需要找到这个脸图的编号,比如说拉尔
  10. #           夫,就是Actor1的编号0,之后去在Graphics/Busts这个文件夹里面拷贝一个
  11. #           叫做Actor1_0的图像,这个图像会被当做半身像替换原有图像。
  12. #==============================================================================
  13. # 2013.8.25 => 修复存档不能Bug (感谢小刀
  14. #==============================================================================
  15. $imported ||= {}
  16. $imported[:LBQ_Bust]=true
  17.  
  18. module LBQ
  19.   module Bust
  20.     FOLDER="Busts"
  21.     SUB1=[/【/,    "\\{\\c[6]-- "]
  22.     SUB2=[/】/,    " --\\c[0]\\}"]
  23.  
  24.     TEXT_FOR_NEXT="[next]"
  25.     TEXT_FOR_END ="[end]"
  26.  
  27.     INDENT=255 #半身像的缩进
  28.   end
  29. end
  30.  
  31. module Cache
  32.   def self.busts(filename)
  33.     load_bitmap("Graphics/#{LBQ::Bust::FOLDER}/", filename)
  34.   end
  35. end
  36.  
  37.  
  38.  
  39. class Sprite_Bust < Sprite_Base
  40.   attr_accessor   :bust_graphics
  41.   attr_accessor   :status
  42.  
  43.   def initialize(vp=nil)
  44.     super(vp)
  45.     @bust_graphics=nil
  46.     @status=:nothing
  47.   end
  48.  
  49.   def slide_in
  50.     @status=:sliding_in
  51.   end
  52.  
  53.   def slide_out
  54.     @status=:sliding_out
  55.     if $game_temp.do_not_slide_out
  56.       @status=:slided_out
  57.       set_pos
  58.     end
  59.   end
  60.  
  61.  
  62.  
  63.  
  64.   def set_pos(slide_in=true)
  65.     self.x=0 - self.bitmap.width
  66.     self.y=Graphics.height-self.bitmap.height
  67.  
  68.     self.x=0 unless slide_in
  69.   end
  70.  
  71.  
  72.   def set_graphics(bust_graphics)
  73.     self.bitmap=Cache.busts(bust_graphics)
  74.   end
  75.  
  76.  
  77.  
  78.   def update
  79.     super
  80.     case @status
  81.     when :nothing
  82.       # Do Nothing
  83.     when :sliding_in
  84.       #Slide In
  85.       self.x+=12
  86.       if self.x>=0
  87.         self.x=0
  88.         @status=:slided_in
  89.       end
  90.  
  91.     when :sliding_out
  92.       self.x-=12
  93.       if self.x<= -self.bitmap.width
  94.         self.x= -self.bitmap.width
  95.         @status=:slided_out
  96.       end
  97.       #Slide Out
  98.     when :slided_in
  99.       #Slided in
  100.     when :slided_out
  101.       #Sliede out
  102.     end
  103.  
  104.   end
  105.  
  106.  
  107. end
  108.  
  109.  
  110.  
  111. class Game_Temp
  112.   attr_accessor   :bust_name
  113.   attr_accessor   :bust
  114.   attr_accessor   :have_bust
  115.   attr_accessor   :do_not_slide_out
  116.  
  117.   alias lbq_bust_shot_game_message_init initialize
  118.   def initialize
  119.     lbq_bust_shot_game_message_init
  120.     @bust_name=""
  121.     @bust=nil
  122.     @have_bust=false
  123.     @do_not_slide_out=false
  124.   end
  125.  
  126.  
  127.  
  128.  
  129. end
  130.  
  131. class Game_Message
  132.    #--------------------------------------------------------------------------
  133.   # ● 添加内容
  134.   #--------------------------------------------------------------------------
  135.   def add(text)
  136.     new_text=text.gsub(LBQ::Bust::SUB1[0],LBQ::Bust::SUB1[1])
  137.     new_text2=new_text.gsub(LBQ::Bust::SUB2[0],LBQ::Bust::SUB2[1])
  138.     if new_text2.include? LBQ::Bust::TEXT_FOR_NEXT
  139.       new_text2.delete!(LBQ::Bust::TEXT_FOR_NEXT)
  140.       $game_temp.do_not_slide_out=true
  141.     end
  142.  
  143.     if new_text2.include? LBQ::Bust::TEXT_FOR_END
  144.       new_text2.delete!(LBQ::Bust::TEXT_FOR_END)
  145.       $game_temp.do_not_slide_out=false
  146.     end
  147.     @texts.push(new_text2)
  148.   end
  149. end
  150.  
  151.  
  152. class Game_Interpreter
  153.   alias lbq_bust_shot_command_101 command_101
  154.   #--------------------------------------------------------------------------
  155.   # ● 显示文字
  156.   #--------------------------------------------------------------------------
  157.   def command_101
  158.     $game_temp.bust=nil
  159.       unless @params[0].empty?
  160.         if File.exist?("Graphics/#{LBQ::Bust::FOLDER}/#{@params[0]}_#{@params[1]}.png")
  161.           $game_temp.have_bust=true
  162.         else
  163.           $game_temp.have_bust=false
  164.           $game_temp.bust_name=""
  165.         end
  166.       end
  167.  
  168.     unless @params[3] == 2
  169.       $game_temp.have_bust=false
  170.     end
  171.  
  172.     if $game_temp.have_bust
  173.       $game_temp.bust_name="#{@params[0]}_#{@params[1]}"
  174.       $game_temp.bust=nil
  175.       $game_temp.bust=Sprite_Bust.new
  176.       $game_temp.bust.set_graphics($game_temp.bust_name)
  177.       $game_temp.bust.z=99999
  178.       unless $game_temp.do_not_slide_out
  179.         $game_temp.bust.set_pos
  180.         $game_temp.bust.slide_in
  181.       else
  182.         $game_temp.bust.set_pos(false)
  183.         $game_temp.bust.slide_in
  184.       end
  185.     end
  186.  
  187.     lbq_bust_shot_command_101
  188.     if $game_temp.have_bust
  189.         $game_temp.bust.slide_out
  190.         Fiber.yield until $game_temp.bust.status==:slided_out
  191.     end
  192.     $game_temp.have_bust=false
  193.     $game_temp.bust_name=""
  194.  
  195.   end
  196.  
  197.  
  198.   alias lbq_bust_int_update update
  199.   def update
  200.     lbq_bust_int_update
  201.     $game_temp.bust.update unless $game_temp.bust.nil?
  202.   end
  203.  
  204. end
  205.  
  206.  
  207. class Window_Message
  208.   #--------------------------------------------------------------------------
  209.   # ● 获取换行位置
  210.   #--------------------------------------------------------------------------
  211.   def new_line_x
  212.     # 如果有头像
  213.     unless $game_message.face_name.empty?
  214.       value=112
  215.       value=LBQ::Bust::INDENT unless $game_temp.bust_name.empty?
  216.     # 木有
  217.     else
  218.       value=0
  219.     end
  220.     return value
  221.   end
  222. end
  223.  
  224.  
  225. class Window_Message
  226.   #--------------------------------------------------------------------------
  227.   # ● 翻页处理
  228.   #--------------------------------------------------------------------------
  229.   def new_page(text, pos)
  230.     contents.clear
  231.     draw_face($game_message.face_name, $game_message.face_index, 0, 0) if $game_temp.bust_name.empty?
  232.     reset_font_settings
  233.     pos[:x] = new_line_x
  234.     pos[:y] = 0
  235.     pos[:new_x] = new_line_x
  236.     pos[:height] = calc_line_height(text)
  237.     clear_flags
  238.   end
  239. end

用法
在"Busts"文件夹里面命名半身像,比如名字是:Actor1_0 则代表这个会自动替换脸图Actor1中的0号(就是拉尔夫)
在句尾打[next]会进入不撤出半身像模式、[end]会结束该模式
作者: liminglun    时间: 2013-6-30 09:12
好棒,马克一个。正需要这个呢
作者: JN1412    时间: 2013-7-26 03:59
如何在某些对话中不需要半身像,半身像为空。那么显示的文字会到后面去,怎么解决这个问题呢?求解...{:2_270:}
作者: Fin丶    时间: 2013-7-26 18:49
如果一个头像有几种状态<如害羞、愤怒等>该如何更换?小白一个....
作者: JN1412    时间: 2013-7-27 00:37
Fin丶 发表于 2013-7-26 18:49
如果一个头像有几种状态该如何更换?小白一个....

这个很简单啊。用PS把表情和半身像拼合一下就行咯!关键是如果在某些对话中不需要半身像时,显示出来的文字怎么靠前一点,不留半身像空出来的地方。
作者: 迷蓝の海    时间: 2013-7-27 17:49
表示用了这个无法存档是怎么回事啊T T……
本来是还不错的脚本的T T
作者: 674998887    时间: 2013-7-28 11:50
打包时,如何将Busts文件一起打出来?

我真的很想问,也是大家想问的。
作者: 674998887    时间: 2013-7-28 11:51
本帖最后由 674998887 于 2013-7-28 11:52 编辑

帮忙删掉我这个回复,连续了。
作者: LBQ    时间: 2013-7-28 21:29
JN1412 发表于 2013-7-26 03:59
如何在某些对话中不需要半身像,半身像为空。那么显示的文字会到后面去,怎么解决这个问题呢?求解...{:2_2 ...
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ 半身像对话框 by LBQ
  4. #------------------------------------------------------------------------------
  5. #  一个简单的半身像对话框罢了= =
  6. #------------------------------------------------------------------------------
  7. # ■ 用法一览
  8. #     1:如何将半身像应用到游戏中?
  9. #       ——如果想要把一个脸图替换成半身像,则需要找到这个脸图的编号,比如说拉尔
  10. #           夫,就是Actor1的编号0,之后去在Graphics/Busts这个文件夹里面拷贝一个
  11. #           叫做Actor1_0的图像,这个图像会被当做半身像替换原有图像。
  12. #==============================================================================
  13. $imported ||= {}
  14. $imported[:LBQ_Bust]=true

  15. module LBQ
  16.   module Bust
  17.     FOLDER="Busts"
  18.     SUB1=[/【/,    "\\{\\c[6]-- "]
  19.     SUB2=[/】/,    " --\\c[0]\\}"]

  20.     TEXT_FOR_NEXT="[next]"
  21.     TEXT_FOR_END ="[end]"

  22.     INDENT=255 #半身像的缩进
  23.   end
  24. end

  25. module Cache
  26.   def self.busts(filename)
  27.     load_bitmap("Graphics/#{LBQ::Bust::FOLDER}/", filename)
  28.   end
  29. end



  30. class Sprite_Bust < Sprite_Base
  31.   attr_accessor   :bust_graphics
  32.   attr_accessor   :status

  33.   def initialize(vp=nil)
  34.     super(vp)
  35.     @bust_graphics=nil
  36.     @status=:nothing
  37.   end

  38.   def slide_in
  39.     @status=:sliding_in
  40.   end

  41.   def slide_out
  42.     @status=:sliding_out
  43.     if $game_message.do_not_slide_out
  44.       @status=:slided_out
  45.       set_pos
  46.     end
  47.   end




  48.   def set_pos(slide_in=true)
  49.     self.x=0 - self.bitmap.width
  50.     self.y=Graphics.height-self.bitmap.height

  51.     self.x=0 unless slide_in
  52.   end


  53.   def set_graphics(bust_graphics)
  54.     self.bitmap=Cache.busts(bust_graphics)
  55.   end



  56.   def update
  57.     super
  58.     case @status
  59.     when :nothing
  60.       # Do Nothing
  61.     when :sliding_in
  62.       #Slide In
  63.       self.x+=12
  64.       if self.x>=0
  65.         self.x=0
  66.         @status=:slided_in
  67.       end

  68.     when :sliding_out
  69.       self.x-=12
  70.       if self.x<= -self.bitmap.width
  71.         self.x= -self.bitmap.width
  72.         @status=:slided_out
  73.       end
  74.       #Slide Out
  75.     when :slided_in
  76.       #Slided in
  77.     when :slided_out
  78.       #Sliede out
  79.     end

  80.   end


  81. end


  82. class Game_Message
  83.   attr_accessor   :bust_name
  84.   attr_accessor   :bust
  85.   attr_accessor   :have_bust
  86.   attr_accessor   :do_not_slide_out

  87.   alias lbq_bust_shot_game_message_init initialize
  88.   def initialize
  89.     lbq_bust_shot_game_message_init
  90.     @bust_name=""
  91.     @bust=nil
  92.     @have_bust=false
  93.     @do_not_slide_out=false
  94.   end



  95.   #--------------------------------------------------------------------------
  96.   # ● 添加内容
  97.   #--------------------------------------------------------------------------
  98.   def add(text)
  99.     new_text=text.gsub(LBQ::Bust::SUB1[0],LBQ::Bust::SUB1[1])
  100.     new_text2=new_text.gsub(LBQ::Bust::SUB2[0],LBQ::Bust::SUB2[1])
  101.     if new_text2.include? LBQ::Bust::TEXT_FOR_NEXT
  102.       new_text2.delete!(LBQ::Bust::TEXT_FOR_NEXT)
  103.       $game_message.do_not_slide_out=true
  104.     end

  105.     if new_text2.include? LBQ::Bust::TEXT_FOR_END
  106.       new_text2.delete!(LBQ::Bust::TEXT_FOR_END)
  107.       $game_message.do_not_slide_out=false
  108.     end
  109.     @texts.push(new_text2)
  110.   end
  111. end



  112. class Game_Interpreter
  113.   alias lbq_bust_shot_command_101 command_101
  114.   #--------------------------------------------------------------------------
  115.   # ● 显示文字
  116.   #--------------------------------------------------------------------------
  117.   def command_101
  118.     $game_message.bust=nil
  119.       unless @params[0].empty?
  120.         if File.exist?("Graphics/#{LBQ::Bust::FOLDER}/#{@params[0]}_#{@params[1]}.png")
  121.           $game_message.have_bust=true
  122.         else
  123.           $game_message.have_bust=false
  124.           $game_message.bust_name=""
  125.         end
  126.       end

  127.     unless @params[3] == 2
  128.       $game_message.have_bust=false
  129.     end

  130.     if $game_message.have_bust
  131.       $game_message.bust_name="#{@params[0]}_#{@params[1]}"
  132.       $game_message.bust=nil
  133.       $game_message.bust=Sprite_Bust.new
  134.       $game_message.bust.set_graphics($game_message.bust_name)
  135.       $game_message.bust.z=99999
  136.       unless $game_message.do_not_slide_out
  137.         $game_message.bust.set_pos
  138.         $game_message.bust.slide_in
  139.       else
  140.         $game_message.bust.set_pos(false)
  141.         $game_message.bust.slide_in
  142.       end
  143.     end

  144.     lbq_bust_shot_command_101
  145.     if $game_message.have_bust
  146.         $game_message.bust.slide_out
  147.         Fiber.yield until $game_message.bust.status==:slided_out
  148.     end
  149.     $game_message.have_bust=false
  150.     $game_message.bust_name=""

  151.   end


  152.   alias lbq_bust_int_update update
  153.   def update
  154.     lbq_bust_int_update
  155.     $game_message.bust.update unless $game_message.bust.nil?
  156.   end

  157. end


  158. class Window_Message
  159.   #--------------------------------------------------------------------------
  160.   # ● 获取换行位置
  161.   #--------------------------------------------------------------------------
  162.   def new_line_x
  163.     value=0
  164.     value=112 unless $game_message.face_name.empty?
  165.     unless $game_message.face_name.empty? && $game_message.bust_name.empty?
  166.       value=LBQ::Bust::INDENT
  167.     end
  168.    
  169.     return value
  170.   end
  171. end


  172. class Window_Message
  173.   #--------------------------------------------------------------------------
  174.   # ● 翻页处理
  175.   #--------------------------------------------------------------------------
  176.   def new_page(text, pos)
  177.     contents.clear
  178.     draw_face($game_message.face_name, $game_message.face_index, 0, 0) if $game_message.bust_name.empty?
  179.     reset_font_settings
  180.     pos[:x] = new_line_x
  181.     pos[:y] = 0
  182.     pos[:new_x] = new_line_x
  183.     pos[:height] = calc_line_height(text)
  184.     clear_flags
  185.   end
  186. end
复制代码
理论上应当修复完毕,对于这个不便深表歉意
作者: JN1412    时间: 2013-7-28 21:55
LBQ 发表于 2013-7-28 21:29
理论上应当修复完毕,对于这个不便深表歉意

那个在特定对话下无需立绘,文字靠后留出立绘位置的问题,昨晚看了看脚本,自己也尝试改了一下。虽然和你的这个有点不一样,但也达到了预期的效果。非常感谢你的脚本,之前还一直在为立绘对话烦恼呐。 嘻嘻...
作者: 唯君    时间: 2013-8-1 23:48
同用完了无法存档……不过脚本很棒……
作者: btbtbtt1    时间: 2013-8-7 10:51
不懂脚本的非常非常非常非常希望能有切换半身像左右出现的功能。。。估计脚本盲想改还真不容易。。
作者: 9jmvq1947    时间: 2013-8-9 16:54
提示: 作者被禁止或删除 内容自动屏蔽
作者: sszny    时间: 2013-8-12 05:13
好棒啊……
作者: 怀念过去    时间: 2013-11-24 12:36
正需要呢
作者: 神原秋人    时间: 2014-2-9 17:53
要求不显示立绘那么就用不了 = =……
作者: 身高一米八    时间: 2014-4-13 20:34
发现了一个可以解决无法存档的办法,就是在用了半身像对话事件的最后加上一个非半身像的对话框。
就是每一个事件后面都要加有点麻烦......
作者: 身高一米八    时间: 2014-4-21 19:03
本帖最后由 身高一米八 于 2014-4-21 19:05 编辑
身高一米八 发表于 2014-4-13 20:34
发现了一个可以解决无法存档的办法,就是在用了半身像对话事件的最后加上一个非半身像的对话框。
就是每一 ...


有无BUG版吗太棒了2333!
作者: 一摸多汁    时间: 2014-9-2 10:28
好像战斗中的对话无法正常显示,如果设定了半身像的头像,头像和半身像都不会显示就一个空白,没有设定半身像的则显示头像


作者: MinamiP    时间: 2015-11-21 17:23
请问大大 可不可以取消立绘从左边移过来这个动作呢?   其实是如果开启了公共事件立绘会飞速的从左边过来,眼睛都花了{:2_280:}
作者: BWR    时间: 2016-10-29 20:38
本帖最后由 BWR 于 2016-10-30 03:36 编辑

腳本我什ˊ麼都沒動,為什麼會這樣呢?

4444.PNG (4.16 KB, 下载次数: 5)

4444.PNG

作者: LBQ    时间: 2016-11-1 00:23
BWR 发表于 2016-10-29 20:38
腳本我什ˊ麼都沒動,為什麼會這樣呢?

因为脚本有些时日了 + 学业繁忙,所以我恐怕需要一个能够直接出现 bug 的工程,或者出现 bug 的步骤我才有可能解决这个问题。

也许脚本本身写的不好会导致这种问题有时发生有时不发生,但是我也没有精力来修自己三年前写的脚本。

所以假如有工程的话希望上传工程嗯。
作者: BWR    时间: 2016-11-1 21:04
LBQ 发表于 2016-11-1 00:23
因为脚本有些时日了 + 学业繁忙,所以我恐怕需要一个能够直接出现 bug 的工程,或者出现 bug 的步骤我才 ...

舊的問題沒了 新的問題來了 嗚嗚嗚
是檔案名稱不能用中文嗎?
我半身像放在資料夾裡了,但遊戲中還是只有96*96的臉圖,不顯示半身像。

01.PNG (697.83 KB, 下载次数: 6)

01.PNG

02.PNG (689.64 KB, 下载次数: 7)

02.PNG

作者: LBQ    时间: 2016-11-2 05:52
BWR 发表于 2016-11-1 21:04
舊的問題沒了 新的問題來了 嗚嗚嗚
是檔案名稱不能用中文嗎?
我半身像放在資料夾裡了,但遊戲中還是只有9 ...

实测发现中文可以,所以假如方便的话上传一个能够重复 bug 的工程。

或者也可以自己试着从中文改成英文。

或者可以对比一下范例看看有没有做错了什么(虽然可能性不大不过还是做一下吧)。
作者: Krabi    时间: 2017-8-13 14:13
好厉害!谢谢!




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1