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

Project1

 找回密码
 注册会员
搜索
查看: 2585|回复: 2

[已经解决] 求教,关于Theo脚本合集动画立绘脚本的问题

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1957
在线时间
410 小时
注册时间
2018-9-25
帖子
38
发表于 2019-11-30 22:23:39 | 显示全部楼层 |阅读模式

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

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

x
脚本小白,想请教一下这个立绘脚本要怎么用,是在事件—脚本里面写吗?但是这样就会报错啊,有人能说一下要怎么来用吗


  1. # =============================================================================
  2. =begin

  3.   -----------------------------------------------------------------------------
  4.   *) 介绍:
  5.   -----------------------------------------------------------------------------
  6.   本脚本可以简单地在对话中显示动态立绘
  7.   
  8.   -----------------------------------------------------------------------------
  9.   *) 使用方法 :
  10.   -----------------------------------------------------------------------------
  11.   本脚本放在插件脚本之下,main之上
  12.   
  13.   准备两张任意尺寸的图片。一个为待机动画,另一个为讲话动画。
  14.   图像本身必须平均分成三格。 把这些图像命名为
  15.   
  16.   文件名_idle.png  << 待机
  17.   文件名_talk.png  << 讲话
  18.   
  19.   -----------------------------------------------------------------------------
  20.   *) 可用脚本:
  21.   -----------------------------------------------------------------------------
  22.   显示动态立绘的脚本
  23.   
  24.   - set_portrait(文件名, 位置, 反转, 激活)
  25.     用于设置立绘,以下为解释
  26.    
  27.     *) 文件名    >> 图片的文件名,必须放在英文引号里("").
  28.                     不用填入 _talk 或 _idle.
  29.     *) 位置      >> 设定立绘位置. 请在 A (左), B (右), 和 C (中)中选择一个
  30.     *) 反转      >> 图片是否左右反转? 填入 true/false. 也可以不用写.
  31.                     默认为false
  32.     *) 激活      >> 是否激活图像?  true时, 当文本逐个现实时,立绘会“讲话”
  33.                     . (默认 : true)
  34.       
  35.   - remove_potrait(位置)
  36.     移除一个立绘. 将"位置"替换为 A, B, 或 C
  37.   
  38.   - active_portrait(位置)
  39.     激活一个立绘. 将"位置"替换为 A, B, 或 C
  40.    
  41.   - clear_portrait
  42.     移除全部立绘,建议在对话结束后都使用一次。
  43.    
  44.   - $game_system.portrait_ypos[位置] = 数值
  45.     重新定位当前显示肖像的位置。
  46.     将"位置替换为" (:A, :B, :C). 将"数值"替换为数字. e.g,
  47.    
  48.     $game_system.portrait_ypos[:B] = 60
  49.   
  50.   -----------------------------------------------------------------------------
  51.   使用规定 :
  52.   署名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
  53.   如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.

  54. =end
复制代码
Snipaste_2019-11-30_22-08-46.png

  1. # =============================================================================
  2. # TheoAllen - 动态立绘
  3. # Version : 1.3
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (English Documentation)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_AnimPortrait] = true
  8. # =============================================================================
  9. # Change Logs:
  10. # -----------------------------------------------------------------------------
  11. # 2014.05.18 - Bugfix, Talk refresh rate wont affect rate
  12. # 2014.01.31 - Added screen y reposition
  13. #            - Show portrait in bottom when placing message window in top
  14. # 2014.01.08 - Added show picture in middle
  15. # 2013.11.14 - Dimmed inactive portrait
  16. #            - Bugfix, when remove portrait
  17. # 2013.10.18 - Finished Script
  18. # =============================================================================
  19. =begin

  20.   -----------------------------------------------------------------------------
  21.   *) 介绍:
  22.   -----------------------------------------------------------------------------
  23.   本脚本可以简单地在对话中显示动态立绘
  24.   
  25.   -----------------------------------------------------------------------------
  26.   *) 使用方法 :
  27.   -----------------------------------------------------------------------------
  28.   本脚本放在插件脚本之下,main之上
  29.   
  30.   准备两张任意尺寸的图片。一个为待机动画,另一个为讲话动画。
  31.   图像本身必须平均分成三格。 把这些图像命名为
  32.   
  33.   文件名_idle.png  << 待机
  34.   文件名_talk.png  << 讲话
  35.   
  36.   -----------------------------------------------------------------------------
  37.   *) 可用脚本:
  38.   -----------------------------------------------------------------------------
  39.   显示动态立绘的脚本
  40.   
  41.   - set_portrait(文件名, 位置, 反转, 激活)
  42.     用于设置立绘,以下为解释
  43.    
  44.     *) 文件名    >> 图片的文件名,必须放在英文引号里("").
  45.                     不用填入 _talk 或 _idle.
  46.     *) 位置      >> 设定立绘位置. 请在 A (左), B (右), 和 C (中)中选择一个
  47.     *) 反转      >> 图片是否左右反转? 填入 true/false. 也可以不用写.
  48.                     默认为false
  49.     *) 激活      >> 是否激活图像?  true时, 当文本逐个现实时,立绘会“讲话”
  50.                     . (默认 : true)
  51.       
  52.   - remove_potrait(位置)
  53.     移除一个立绘. 将"位置"替换为 A, B, 或 C
  54.   
  55.   - active_portrait(位置)
  56.     激活一个立绘. 将"位置"替换为 A, B, 或 C
  57.    
  58.   - clear_portrait
  59.     移除全部立绘,建议在对话结束后都使用一次。
  60.    
  61.   - $game_system.portrait_ypos[位置] = 数值
  62.     重新定位当前显示肖像的位置。
  63.     将"位置替换为" (:A, :B, :C). 将"数值"替换为数字. e.g,
  64.    
  65.     $game_system.portrait_ypos[:B] = 60
  66.   
  67.   -----------------------------------------------------------------------------
  68.   使用规定 :
  69.   署名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
  70.   如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.

  71. =end
  72. # =============================================================================
  73. # 设定
  74. # =============================================================================
  75. module Theo
  76.   module AnimePortrait
  77.    
  78.   # --------------------------------------------------------------------------
  79.     Talk_Refresh_Rate = 4
  80.   # 当前激活立绘的刷新率。如果你设定为4,则图像会每4个字符出现后刷新一次。
  81.   # 默认值为4.
  82.   # --------------------------------------------------------------------------
  83.   
  84.   # --------------------------------------------------------------------------
  85.     Idle_Interval = [20,120]
  86.   # 待机动画的间隔等待时间. 格式为 [绝对等待时间, 随机等待时间]
  87.   #
  88.   # *) 绝对等待时间    >> 绝对等待时间(帧)
  89.   # *) 随机等待时间    >> 随机等待时间(帧)
  90.   #
  91.   # 如果你设定为 [20,120] 意为等待动画之间的间隔 = 20帧 + 0~120的随机值
  92.   # (默认 : [20,120])
  93.   #
  94.   # 注意 : 60 帧 = 1 秒
  95.   # --------------------------------------------------------------------------
  96.    
  97.   # --------------------------------------------------------------------------
  98.     Use_Dim   = true    # 是否使用暗淡化效果
  99.     Dim_Power = 90      # 暗淡强度 (默认 : 90)
  100.   # --------------------------------------------------------------------------
  101.   # 暗淡效果用于"不讲话"的那个立绘
  102.   # --------------------------------------------------------------------------
  103.   end
  104. end
  105. # =============================================================================
  106. # 设定结束
  107. # =============================================================================
  108. class Game_System
  109.   attr_reader :portrait_ypos
  110.   
  111.   alias theo_animportrait_init initialize
  112.   def initialize
  113.     theo_animportrait_init
  114.     @portrait_ypos = {
  115.     :A => 0,
  116.     :B => 0,
  117.     :C => 0,
  118.     }
  119.   end
  120.   
  121. end

  122. class Game_Interpreter
  123.   A = :A  # Kiri
  124.   B = :B  # Kanan
  125.   C = :C  # Tengah
  126.   
  127.   def set_portrait(filename, pos, flip = false, active = true)
  128.     $game_message.animportrait_name[pos] = [filename, flip]
  129.     $game_message.active_portrait = pos if active
  130.   end
  131.   
  132.   def clear_portrait
  133.     $game_message.reset_animportrait
  134.   end
  135.   
  136.   def remove_portrait(pos)
  137.     $game_message.animportrait_name[pos][0] = ""
  138.   end
  139.   
  140.   def active_portrait(pos)
  141.     $game_message.active_portrait = pos
  142.   end
  143.   
  144. end

  145. class Game_Message
  146.   attr_accessor :active_portrait
  147.   attr_reader :animportrait_name
  148.   
  149.   alias theo_animportrait_init initialize
  150.   def initialize
  151.     theo_animportrait_init
  152.     reset_animportrait
  153.     @active_portrait = :A
  154.   end
  155.   
  156.   def reset_animportrait
  157.     @animportrait_name = {
  158.       :A => ["", false],
  159.       :B => ["", false],
  160.       :C => ["", false],
  161.     }
  162.   end
  163.   
  164. end

  165. class AnimPortrait < Sprite
  166.   include Theo::AnimePortrait
  167.   Dimmed_Color = Color.new(0,0,0,Dim_Power)
  168.   Normal_Color = Color.new(0,0,0,0)
  169.   attr_accessor :self_switch  # Self Activation ~
  170.   
  171.   def initialize(pos, msg_window, viewport = nil)
  172.     super(viewport)
  173.     self.z = 150
  174.     @msg_window = msg_window
  175.     @pos = pos
  176.     @self_switch = false
  177.     @idle_pattern = 0
  178.     @fiber = nil
  179.     init_bitmap
  180.     generate_idle_count
  181.   end
  182.   
  183.   def init_bitmap
  184.     @filename = img_name
  185.     self.bitmap = Cache.system(@filename)
  186.     self.mirror = $game_message.animportrait_name[@pos][1]
  187.     case @pos
  188.     when :A
  189.       self.x = 0
  190.     when :B
  191.       self.x = Graphics.width - width
  192.     when :C
  193.       self.x = (Graphics.width - width) / 2
  194.     end
  195.   end
  196.   
  197.   def img_name
  198.     str = $game_message.animportrait_name[@pos][0]
  199.     return "" if str.empty?
  200.     return str + (active? ? "_talk" : "_idle")
  201.   end
  202.   
  203.   def bitmap=(bmp)
  204.     super
  205.     src_rect.width = bitmap.width / 3
  206.   end
  207.   
  208.   def generate_idle_count
  209.     @idle_count = random_idle_number
  210.   end
  211.   
  212.   def random_idle_number
  213.     return Idle_Interval[0] + rand(Idle_Interval[1])
  214.   end
  215.   
  216.   def update
  217.     super
  218.     self.y = ypos_case
  219.     self.opacity = @msg_window.openness
  220.     update_bitmap
  221.     update_color if Use_Dim
  222.     update_idle unless active?
  223.   end
  224.   
  225.   def ypos_case
  226.     return Graphics.height - height + $game_system.portrait_ypos[@pos] if
  227.       $game_message.position == 0
  228.     return @msg_window.y - height + $game_system.portrait_ypos[@pos]
  229.   end
  230.   
  231.   def update_bitmap
  232.     if @filename != img_name
  233.       init_bitmap
  234.     end
  235.   end
  236.   
  237.   def update_color
  238.     if pos_active?
  239.       self.color = Normal_Color
  240.     else
  241.       self.color = Dimmed_Color
  242.     end
  243.   end
  244.   
  245.   def update_active
  246.     @fiber = nil if @fiber
  247.     set_src_rect(rand(3))
  248.   end
  249.   
  250.   def active?
  251.     return pos_active? && self_switch
  252.   end
  253.   
  254.   def pos_active?
  255.     @pos == $game_message.active_portrait
  256.   end
  257.   
  258.   def update_idle
  259.     if @fiber
  260.       @fiber.resume
  261.     elsif @idle_count == 0
  262.       @fiber = Fiber.new { fiber_idle }
  263.     else
  264.       @idle_count -= 1
  265.     end
  266.   end
  267.   
  268.   def fiber_idle
  269.     setup_idle_anim
  270.     update_idle_src_rect
  271.     terminate_idle_anim
  272.   end
  273.   
  274.   def setup_idle_anim
  275.     set_src_rect(0)
  276.   end
  277.   
  278.   def update_idle_src_rect
  279.     random_wait
  280.     set_src_rect(1)
  281.     random_wait
  282.     set_src_rect(2)
  283.     random_wait
  284.     set_src_rect(1)
  285.     random_wait
  286.     set_src_rect(0)
  287.     random_wait
  288.   end
  289.   
  290.   def set_src_rect(amount)
  291.     @pattern = amount
  292.     src_rect.x = @pattern * bitmap.width/3
  293.   end
  294.   
  295.   def random_wait
  296.     (2 + rand(3)).times { Fiber.yield }
  297.   end
  298.   
  299.   def terminate_idle_anim
  300.     @fiber = nil
  301.     generate_idle_count
  302.   end
  303.   
  304.   def dispose
  305.     bitmap.dispose
  306.     super
  307.   end
  308.   
  309. end

  310. class Window_Message < Window_Base
  311.   
  312.   alias theo_animportrait_init initialize
  313.   def initialize
  314.     theo_animportrait_init
  315.     create_animportrait
  316.   end
  317.   
  318.   def create_animportrait
  319.     @animportrait = {
  320.       :A => AnimPortrait.new(:A, self, viewport),
  321.       :B => AnimPortrait.new(:B, self, viewport),
  322.       :C => AnimPortrait.new(:C, self, viewport),
  323.     }
  324.     @talk_anim = 0
  325.   end
  326.   
  327.   def active_portrait
  328.     @animportrait[$game_message.active_portrait]
  329.   end
  330.   
  331.   alias theo_animportrait_process_all_text process_all_text
  332.   def process_all_text
  333.     active_portrait.self_switch = true
  334.     theo_animportrait_process_all_text
  335.   end
  336.   
  337.   alias theo_animportrait_updt_show_fast update_show_fast
  338.   def update_show_fast
  339.     theo_animportrait_updt_show_fast
  340.     active_portrait.set_src_rect(0) if Input.trigger?(:C)
  341.   end
  342.   
  343.   alias theo_animportrait_wait_for_one_char wait_for_one_character
  344.   def wait_for_one_character
  345.     theo_animportrait_wait_for_one_char
  346.     @talk_anim += 1
  347.     refrate = Theo::AnimePortrait::Talk_Refresh_Rate
  348.     active_portrait.update_active if @talk_anim % refrate == 0
  349.   end
  350.   
  351.   alias theo_animportrait_process_input process_input
  352.   def process_input
  353.     active_portrait.set_src_rect(0)
  354.     active_portrait.self_switch = false
  355.     theo_animportrait_process_input
  356.   end
  357.   
  358.   alias theo_animportrait_update update
  359.   def update
  360.     theo_animportrait_update
  361.     @animportrait.values.each {|img| img.update }
  362.   end
  363.   
  364.   alias theo_animportrait_dispose dispose
  365.   def dispose
  366.     theo_animportrait_dispose
  367.     @animportrait.values.each {|img| img.dispose }
  368.   end
  369.   
  370.   alias theo_animportrait_wait wait
  371.   def wait(duration)
  372.     active_portrait.set_src_rect(0)
  373.     theo_animportrait_wait(duration)
  374.   end
  375.   
  376. end
复制代码






Lv5.捕梦者

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

R考场第七期纪念奖

发表于 2019-11-30 23:18:59 | 显示全部楼层
本帖最后由 KB.Driver 于 2019-11-30 23:28 编辑

用法是事件脚本没错。
我觉得问题可能是你使用了全角字符的括号即(
检查一下字符是否为半角,比如半角括号(和逗号,

我给你完美还原了一下你的问题,详见折叠内容

点评

居然是字符,好蠢的错误啊。。  发表于 2019-12-1 00:50

评分

参与人数 1星屑 +40 收起 理由
VIPArcher + 40 认可答案

查看全部评分

用头画头像,用脚写脚本
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 06:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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