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

Project1

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

[已经解决] 隐藏房间黑块的脚本和Galv行走图效果冲突

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1188
在线时间
100 小时
注册时间
2022-1-14
帖子
29
跳转到指定楼层
1
发表于 2022-4-5 13:46:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 IndigoIX 于 2022-4-5 13:48 编辑

虽然总体上不会对游戏运行造成什么影响,但这两个脚本放在一起,只要一从别的Scene返回Scene_Map,生成的隐藏房间黑块就会突然闪一下……影响游戏体验
个人推测是因为两个脚本都要从事件注释里读取设置造成的影响,想请教一下怎么解决这点……
附上脚本和工程……
RUBY 代码复制
  1. #------------------------------------------------------------------------------#
  2. #  Galv's 行走图效果
  3. #------------------------------------------------------------------------------#
  4. #  For: RPGMAKER VX ACE
  5. #  Version 2.1
  6. #------------------------------------------------------------------------------#
  7. #  2014-01-16 - Version 2.1 - Fixed double balloon/animation bug with shadows
  8. #  2013-12-07 - Version 2.0 - Added comments to more easily add event effects
  9. #                           - Fixed shadow facing bug
  10. #  2013-02-24 - Version 1.9 - added z level option for reflection and shadows
  11. #  2013-02-23 - Version 1.8 - added multiple light sources for shadows
  12. #  2013-02-22 - Version 1.7 - bug fixes
  13. #  2013-02-22 - Version 1.6 - added icon effect
  14. #  2013-02-22 - Version 1.5 - fixed mirror bug on large maps
  15. #  2013-02-22 - Version 1.4 - added effects to vehicles
  16. #  2013-02-21 - Version 1.3 - fixed jump reflection and other minor tweaks
  17. #  2013-02-21 - Version 1.2 - bug with less than 4 actors (oops)
  18. #  2013-02-21 - Version 1.1 - updated flicker effect
  19. #  2013-02-21 - Version 1.0 - release
  20. #------------------------------------------------------------------------------#
  21. #  可以为地图上的事件、队友、角色添加一些特效.
  22. #  当前特效有:
  23. #
  24. #  影子
  25. #  根据光源位置显示玩家和事件影子.
  26. #
  27. #  地面反射
  28. #  可以显示水面倒影、地板反射,想做到和demo一样的效果,你需要自己去编辑.
  29. #
  30. #  墙壁反射
  31. #  和反射很像,只是反射成像在墙壁上的镜子里.
  32. #
  33. #------------------------------------------------------------------------------#
  34.  
  35.  
  36. #------------------------------------------------------------------------------#
  37. #  新功能 - 事件页第一条插入注释
  38. #------------------------------------------------------------------------------#
  39. #  在事件页的第一行使用以下注释,可以设定事件使用的效果,如果一个事件使用多种效
  40. #  果,所有效果必须要放在同一行.
  41. #
  42. # <icon:id,x,y>      # 在事件身上显示图标 (x 坐标偏移量,y 坐标偏移量)
  43. # <shadow>           # 事件显示影子
  44. # <reflect>          # 事件显示反射 (包括地面和墙壁反射)
  45. #
  46. #------------------------------------------------------------------------------#
  47. #  例子:
  48. # <icon:1,0,0><shadow><reflect>    # 事件显示1号图标、影子和反射
  49. #------------------------------------------------------------------------------#
  50.  
  51.  
  52. #------------------------------------------------------------------------------#
  53. #  可用脚本:
  54. #------------------------------------------------------------------------------#
  55. #
  56. #  char_effects(x,x,x,true/false)
  57. #
  58. #------------------------------------------------------------------------------#
  59. #  # 启用或禁用当前地图中的单个/多个行走图效果.
  60. #  # 将x替换为代表效果的数字
  61. #  # 0 = 地面反射    1 = 影子    2 = 墙壁反射    3 = 图标
  62. #------------------------------------------------------------------------------#
  63. #  EXAMPLES:
  64. #  char_effects(0,true)              # 启用地面反射效果
  65. #  char_effects(0,2,true)            # 启用地面和墙壁反射效果
  66. #  char_effects(1,3,false)           # 禁用影子和图标效果
  67. #------------------------------------------------------------------------------#
  68. #
  69. #  reflect_sprite(角色_id,文件名,索引)    # 改变角色的反射图像(包括地面和墙壁反射)
  70. #
  71. #  reflect_esprite(事件_id,文件名,索引)   # 改变事件的反射图像(包括地面和墙壁反射)
  72. #
  73. #  reflect_vsprite(载具_id,文件名,索引)   # 改变载具的反射图像(包括地面和墙壁反射)
  74. #
  75. #------------------------------------------------------------------------------#
  76. #  自理:
  77. #  reflect_sprite(1,"Actor2",2)      # 1号角色使用行走图"Actor2"中2号索引的图像.
  78. #  reflect_esprite(3,"Actor4",5)     # 3号事件使用行走图"Actor4"中5号索引的图像.
  79. #  reflect_vsprite(1,"Vehicle",5)    # 船使用行走图"Vehicle"中5号索引的图像.
  80. #------------------------------------------------------------------------------#
  81.  
  82. #------------------------------------------------------------------------------#
  83. #  启用/禁用单个/多个事件的脚本
  84. #------------------------------------------------------------------------------#
  85. #
  86. #  reflect(x,x,x,true/false)   # 启用/禁用x号事件的某效果. x替换为事件id
  87. #  shadow(x,x,x,true/false)    # 可以使用 :all 代表所有事件  
  88. #  icon(x,x,x,图标_id)         # 图标_id = 0 时为无图标
  89. #
  90. #------------------------------------------------------------------------------#
  91. #  例子:
  92. #  reflect(14,17,3,1,true) # 启用14、17、3、1号事件的反射效果(包括地面和墙壁反射)
  93. #  shadow(1,false)         # 禁用1号事件的影子效果
  94. #  reflect(:all,true)      # 启用所有事件的反射效果
  95. #  icon(1,2,3,4,38)        # 1、2、3、4号事件头上显示38号图标
  96. #
  97. #  注意: 为了防止卡顿,玩家进入某地图时,所有事件默认禁用影子和反射效果
  98. #        你需要使用脚本或添加事件注释的方式手动指定事件要显示的效果.
  99. #------------------------------------------------------------------------------#
  100.  
  101. #------------------------------------------------------------------------------#
  102. #  启用/禁用角色/载具效果的脚本
  103. #------------------------------------------------------------------------------#
  104. #
  105. #  actor_reflect(角色_id,true/false)  # 角色和载具默认启用反射和影子效果
  106. #  actor_shadow(角色_id,true/false)   # 使用脚本改变其显示设定后,会永久性生效
  107. #  actor_icon(角色_id,图标_id)        # 不会因为切换地图而恢复默认设定.
  108. #
  109. #  v_reflect(x,x,x,true/false)  
  110. #  v_shadow(x,x,x,true/false)   
  111. #  v_icon(x,x,x,图标_id)
  112. #
  113. #------------------------------------------------------------------------------#
  114.  
  115. #------------------------------------------------------------------------------#
  116. #  影子设定的脚本
  117. #------------------------------------------------------------------------------#
  118. #
  119. #  shadow_source(x,y,光源id)       # 设定光源的x、y坐标,和使用的光源id
  120. #                                  # 场所移动后设定会被重置.
  121. #
  122. #  shadow_source(事件_id,光源id)  # 光源在某个事件的位置上.
  123. #                                 # 当光源移动时需要事件的触发条件为“并行处理”
  124. #
  125. #  shadow_options(强度,淡出,明灭效果)    # 下面有说明
  126. #
  127. #    # 强度 = 站在光源旁边时,影子的不透明度 (255 = 全黑)
  128. #    # 淡出 = 玩家离光源越远,影子不透明度减小的值.
  129. #    # 明灭效果 = true 或 false. 模拟火堆的明灭闪烁效果.
  130. #
  131. #------------------------------------------------------------------------------#
  132. #  例子:
  133. #  shadow_options(80,10,false)    # 默认设定:强度=80、淡出=10、不显示明灭效果.
  134. #------------------------------------------------------------------------------#
  135.  
  136. #------------------------------------------------------------------------------#
  137. #  反射设定的脚本
  138. #------------------------------------------------------------------------------#
  139. #
  140. #  reflect_options(波动强度)
  141. #
  142. #    # 波动强度 = 波动强度的大小. 0 = 不显示波动效果
  143. #
  144. #------------------------------------------------------------------------------#
  145. #  例子:
  146. #  reflect_options(1) # 波动强度 = 1
  147. #------------------------------------------------------------------------------#
  148.  
  149.  
  150. #------------------------------------------------------------------------------#
  151. #  角色备注
  152. #------------------------------------------------------------------------------#
  153. #
  154. #  <no_reflect>    # 该角色不显示反射 (当然是吸血鬼啦!)
  155. #
  156. #  <reflect_sprite: 文件名,索引>   # 设定角色的反射图像和索引
  157. #
  158. #------------------------------------------------------------------------------#
  159. #  例子:
  160. #  <reflect_sprite: Actor2,0>   
  161. #  <reflect_sprite: Actor3,7>   
  162. #------------------------------------------------------------------------------#
  163.  
  164.  
  165. ($imported ||= {})["Galv_Character_Effects"] = true
  166. module Galv_CEffects
  167.  
  168. #------------------------------------------------------------------------------#  
  169. #  脚本设定部分
  170. #------------------------------------------------------------------------------#
  171.  
  172.   MIRROR_REGION = 1     # 墙壁反射的区域id. 在代表墙壁的地图(必须是空白图快)
  173.                         # 中画该id的区域
  174.                         # 然后可以使用远景图或地图图层显示反射的地图区域
  175.  
  176.   ICON_OFFSET = -60     # 图标离行走图多少像素的高度(Y坐标偏移量)
  177.  
  178.   REFLECT_Z = -10       # 反射图像的Z坐标
  179.   SHADOW_Z = 0          # 影子图像的Z坐标
  180.  
  181. #------------------------------------------------------------------------------#  
  182. #  END SETUP OPTIONS
  183. #------------------------------------------------------------------------------#
  184. end
  185.  
  186.  
  187.  
  188.  
  189. class Game_Map
  190.   def do_icons(refresh = true)
  191.     @events.values.each { |e|
  192.       next if !e.list
  193.       if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<icon:(.*),(.*),(.*)>/
  194.         e.icon = $1.to_i
  195.         e.icon_offset = [$2.to_i,$3.to_i]
  196.       else
  197.         e.icon = 0
  198.         e.icon_offset = [0,0]
  199.       end
  200.     }
  201.     SceneManager.scene.spriteset.refresh_effects if refresh
  202.   end
  203.  
  204.  
  205.   def do_shadows(refresh = true)
  206.     @events.values.each { |e|
  207.       next if !e.list
  208.       if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<shadow>/
  209.         e.shadow = true
  210.       else
  211.         e.shadow = false
  212.       end
  213.     }
  214.     SceneManager.scene.spriteset.refresh_effects if refresh
  215.   end
  216.  
  217.   def do_reflects(refresh = true)
  218.     @events.values.each { |e|
  219.       next if !e.list
  220.       if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<reflect>/
  221.         e.reflect = true
  222.       else
  223.         e.reflect = false
  224.       end
  225.     }
  226.     SceneManager.scene.spriteset.refresh_effects if refresh
  227.   end
  228.  
  229.   def do_all_chareffects
  230.     do_icons(false)
  231.     do_shadows(false)
  232.     do_reflects(false)
  233.   end
  234.  
  235. end # Game_Map
  236.  
  237.  
  238.  
  239.  
  240. class Game_Interpreter
  241.  
  242.   def remove_icon
  243.     icon(@event_id,0)
  244.   end
  245.  
  246. #-----------------------------------#
  247. #  REFLECTIONS
  248. #-----------------------------------#
  249.  
  250.   # Add/Remove Reflections from selected events
  251.   def reflect(*args,status)
  252.     char_ids = [*args]
  253.     if char_ids == [:all]
  254.       $game_map.events.values.each { |e| e.reflect = status }
  255.     else
  256.       char_ids.each {|c| $game_map.events[c].reflect = status }
  257.     end
  258.     SceneManager.scene.spriteset.refresh_effects
  259.   end
  260.  
  261.   # Change forever actor's reflect status
  262.   def actor_reflect(actor_id,status)
  263.     $game_actors[actor_id].reflect = status
  264.     $game_player.refresh
  265.   end
  266.  
  267.   # Change forever vehicle's reflect status
  268.   def v_reflect(*args,status)
  269.     char_ids = [*args]
  270.     if char_ids == [:all]
  271.       $game_map.vehicles.each { |v| v.reflect = status }
  272.     else
  273.       char_ids.each { |v| $game_map.vehicles[v].reflect = status }
  274.     end
  275.     SceneManager.scene.spriteset.refresh_effects
  276.   end
  277.  
  278.   def reflect_options(*args)
  279.     $game_map.reflect_options = [*args]
  280.     SceneManager.scene.spriteset.refresh_effects
  281.   end
  282.  
  283.   # Actor reflect sprite change
  284.   def reflect_sprite(actor_id,filename,pos)
  285.     $game_actors[actor_id].reflect_sprite = [filename,pos]
  286.     $game_player.refresh
  287.   end
  288.  
  289.   # Event reflect sprite change
  290.   def reflect_esprite(event_id,filename,pos)
  291.     $game_map.events[event_id].reflect_sprite = [filename,pos]
  292.     $game_map.events[event_id].reflect = true
  293.     SceneManager.scene.spriteset.refresh_characters
  294.   end
  295.  
  296.   # Vehicle reflect sprite change
  297.   def reflect_vsprite(v_id,filename,pos)
  298.     $game_map.vehicles[v_id].reflect_sprite = [filename,pos]
  299.     SceneManager.scene.spriteset.refresh_characters
  300.   end
  301.  
  302. #-----------------------------------#
  303. #  SHADOWS
  304. #-----------------------------------#
  305.  
  306.   # Add/Remove Shadows from selected characters
  307.   def shadow(*args,status)
  308.     char_ids = [*args]
  309.     if char_ids == [:all]
  310.       $game_map.events.values.each { |e| e.shadow = status }
  311.     else
  312.       char_ids.each {|c| $game_map.events[c].shadow = status }
  313.     end
  314.     SceneManager.scene.spriteset.refresh_effects
  315.   end
  316.  
  317.   # Change player and follower shadows
  318.   def actor_shadows(status)
  319.     $game_player.shadow = status
  320.     $game_player.followers.each { |f| f.shadow = status }
  321.     SceneManager.scene.spriteset.refresh_effects
  322.   end
  323.  
  324.   # Change vehicle's shadow status
  325.   def v_shadow(*args,status)
  326.     char_ids = [*args]
  327.     if char_ids == [:all]
  328.       $game_map.vehicles.each { |v| v.shadow = status }
  329.     else
  330.       char_ids.each { |v| $game_map.vehicles[v].shadow = status }
  331.     end
  332.     SceneManager.scene.spriteset.refresh_effects
  333.   end
  334.  
  335.   def shadow_options(*args)
  336.     $game_map.shadow_options = [*args]
  337.     SceneManager.scene.spriteset.refresh_effects
  338.   end
  339.  
  340.   def shadow_source(*args,shad_id)
  341.     shadsource = [*args]
  342.  
  343.     if shadsource.count == 1
  344.       $game_map.light_source[shad_id] = [$game_map.events[shadsource[0]].real_x,
  345.         $game_map.events[shadsource[0]].real_y]
  346.     elsif shadsource.count > 1
  347.       $game_map.light_source[shad_id] = shadsource
  348.     else
  349.       $game_map.light_source = []
  350.     end
  351.   end
  352.  
  353.  
  354. #-----------------------------------#
  355. #  ICONS
  356. #-----------------------------------#
  357.  
  358.   # Add/Remove Icons from selected events
  359.   def icon(*args,icon_id)
  360.     char_ids = [*args]
  361.     if char_ids == [:all]
  362.       $game_map.events.values.each { |e|
  363.       if e.icon <= 0
  364.         e.icon = nil
  365.       else
  366.         e.icon = icon_id
  367.       end
  368.     }
  369.     else
  370.       char_ids.each {|c| $game_map.events[c].icon = icon_id }
  371.     end
  372.     SceneManager.scene.spriteset.refresh_effects
  373.   end
  374.  
  375.   # Change forever actor's icon
  376.   def actor_icon(actor_id,icon_id)
  377.     $game_actors[actor_id].icon = icon_id
  378.     $game_player.refresh
  379.   end
  380.  
  381.   # Change forever vehicle's icon
  382.   def v_icon(*args,icon_id)
  383.     char_ids = [*args]
  384.     if char_ids == [:all]
  385.       $game_map.vehicles.each { |v| v.icon = icon_id }
  386.     else
  387.       char_ids.each { |v| $game_map.vehicles[v].icon = icon_id }
  388.     end
  389.     SceneManager.scene.spriteset.refresh_effects
  390.   end
  391.  
  392. #-----------------------------------#
  393. #  GENERAL
  394. #-----------------------------------#
  395.  
  396.   # Turn on/off effects
  397.     # 0 = reflect
  398.     # 1 = shadow
  399.     # 2 = mirror
  400.     # 3 = icon
  401.  
  402.   def char_effects(*args,status)
  403.     [*args].each { |e| $game_map.char_effects[e] = status }
  404.     SceneManager.scene.spriteset.refresh_effects
  405.   end
  406.  
  407.  
  408. end # Game_Interpreter
  409.  
  410.  
  411. #-------------------------------------------------------------------------------
  412. #  Spriteset_Map
  413. #-------------------------------------------------------------------------------
  414.  
  415. class Spriteset_Map
  416.   alias galv_reflect_sm_initialize initialize
  417.   def initialize
  418.     create_effects
  419.     galv_reflect_sm_initialize
  420.     refresh_characters
  421.   end
  422.  
  423.   alias galv_reflect_sm_refresh_characters refresh_characters
  424.   def refresh_characters
  425.     galv_reflect_sm_refresh_characters
  426.     create_effects
  427.   end
  428.  
  429.   def refresh_effects
  430.     dispose_effects
  431.     create_effects
  432.   end
  433.  
  434.   def create_effects
  435.     @shadow_sprites = []
  436.     @reflect_sprites = []
  437.     @mirror_sprites = []
  438.     @icon_sprites = []
  439.  
  440.     # Do reflections
  441.     if $game_map.char_effects[0]
  442.       $game_map.events.values.each { |e|
  443.         @reflect_sprites.push(Sprite_Reflect.new(@viewport1, e)) if e.reflect
  444.       }
  445.       $game_player.followers.each { |f|
  446.         @reflect_sprites.push(Sprite_Reflect.new(@viewport1, f)) if f.reflect
  447.       }
  448.       if $game_player.reflect
  449.         @reflect_sprites.push(Sprite_Reflect.new(@viewport1, $game_player))
  450.       end
  451.       $game_map.vehicles.each { |v|
  452.         @reflect_sprites.push(Sprite_Reflect.new(@viewport1, v)) if v.reflect
  453.       }
  454.     end
  455.  
  456.     # Do mirrors
  457.     if $game_map.char_effects[2]
  458.       $game_map.events.values.each { |e|
  459.         @mirror_sprites.push(Sprite_Mirror.new(@viewport1, e)) if e.reflect
  460.       }
  461.       $game_player.followers.each { |f|
  462.         @mirror_sprites.push(Sprite_Mirror.new(@viewport1, f)) if f.reflect
  463.       }
  464.       if $game_player.reflect
  465.         @mirror_sprites.push(Sprite_Mirror.new(@viewport1, $game_player))
  466.       end
  467.       $game_map.vehicles.each { |v|
  468.         @mirror_sprites.push(Sprite_Mirror.new(@viewport1, v)) if v.reflect
  469.       }
  470.     end
  471.  
  472.     # Do Shadows
  473.     if $game_map.char_effects[1]
  474.       return if $game_map.light_source.empty?
  475.       $game_map.light_source.count.times { |s|
  476.         $game_map.events.values.each { |e|
  477.           @shadow_sprites.push(Sprite_Shadow.new(@viewport1, e, s)) if e.shadow
  478.         }
  479.         $game_player.followers.each { |f|
  480.           @shadow_sprites.push(Sprite_Shadow.new(@viewport1, f, s)) if f.shadow
  481.         }
  482.         if $game_player.shadow
  483.           @shadow_sprites.push(Sprite_Shadow.new(@viewport1, $game_player, s))
  484.         end
  485.         $game_map.vehicles.each { |v|
  486.           @shadow_sprites.push(Sprite_Shadow.new(@viewport1, v, s)) if v.shadow
  487.         }
  488.       }
  489.     end
  490.  
  491.     # Do icons
  492.     if $game_map.char_effects[3]
  493.       $game_map.events.values.each { |e|
  494.         @icon_sprites.push(Sprite_Icon.new(@viewport1, e)) if e.icon
  495.       }
  496.       $game_player.followers.each { |f|
  497.         @icon_sprites.push(Sprite_Icon.new(@viewport1, f)) if f.icon
  498.       }
  499.       if $game_player.icon
  500.         @icon_sprites.push(Sprite_Icon.new(@viewport1, $game_player))
  501.       end
  502.       $game_map.vehicles.each { |v|
  503.         @icon_sprites.push(Sprite_Icon.new(@viewport1, v)) if v.icon
  504.       }
  505.     end
  506.   end
  507.  
  508.   alias galv_reflect_sm_update update
  509.   def update
  510.     galv_reflect_sm_update
  511.     @reflect_sprites.each {|s| s.update} if $game_map.char_effects[0]
  512.     @mirror_sprites.each {|s| s.update} if $game_map.char_effects[2]
  513.     @shadow_sprites.each {|s| s.update} if $game_map.char_effects[1]
  514.     @icon_sprites.each {|s| s.update} if $game_map.char_effects[3]
  515.   end
  516.  
  517.   alias galv_reflect_sm_dispose_characters dispose_characters
  518.   def dispose_characters
  519.     galv_reflect_sm_dispose_characters
  520.     dispose_effects
  521.   end
  522.  
  523.   def dispose_effects
  524.     @reflect_sprites.each {|s| s.dispose}
  525.     @shadow_sprites.each {|s| s.dispose}
  526.     @mirror_sprites.each {|s| s.dispose}
  527.     @icon_sprites.each {|s| s.dispose}
  528.   end
  529. end # Spriteset_Map
  530.  
  531.  
  532. #-------------------------------------------------------------------------------
  533. #  Sprite_Reflect
  534. #-------------------------------------------------------------------------------
  535.  
  536. class Sprite_Reflect < Sprite_Character
  537.   def initialize(viewport, character = nil)
  538.     super(viewport, character)
  539.   end
  540.  
  541.   def update
  542.     super
  543.   end
  544.  
  545.   def update_balloon; end
  546.   def setup_new_effect; end
  547.  
  548.   def set_character_bitmap
  549.     if @character.reflect_sprite
  550.       self.bitmap = Cache.character(@character.reflect_sprite[0])
  551.     else
  552.       self.bitmap = Cache.character(@character_name)
  553.     end
  554.     self.mirror = true
  555.     self.angle = 180
  556.     self.opacity = 220
  557.     self.z = Galv_CEffects::REFLECT_Z
  558.     self.wave_amp = $game_map.reflect_options[0]
  559.  
  560.     sign = @character_name[/^[\!\$]./]
  561.     if sign && sign.include?('$')
  562.       @cw = bitmap.width / 3
  563.       @ch = bitmap.height / 4
  564.     else
  565.       @cw = bitmap.width / 12
  566.       @ch = bitmap.height / 8
  567.     end
  568.     self.ox = @cw / 2
  569.     self.oy = @ch
  570.   end
  571.  
  572.   def update_position
  573.     self.x = @character.screen_x
  574.     jump = @character.jumping? ? @character.jump_height * 2 : 0
  575.     alt = @character.altitude ? @character.altitude * 2 : 0
  576.     self.y = @character.screen_y - 3 + jump + alt
  577.   end
  578.  
  579.   def update_other
  580.     self.blend_type = @character.blend_type
  581.     self.visible = !@character.transparent
  582.   end
  583.  
  584.   def update_src_rect
  585.     if @character.reflect_sprite
  586.       index = @character.reflect_sprite[1]
  587.     else
  588.       index = @character.character_index
  589.     end
  590.     pattern = @character.pattern < 3 ? @character.pattern : 1
  591.     sx = (index % 4 * 3 + pattern) * @cw
  592.     sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
  593.     self.src_rect.set(sx, sy, @cw, @ch)
  594.   end
  595. end # Sprite_Reflect < Sprite_Character
  596.  
  597.  
  598. #-------------------------------------------------------------------------------
  599. #  Sprite_Mirror
  600. #-------------------------------------------------------------------------------
  601.  
  602. class Sprite_Mirror < Sprite_Character
  603.   def initialize(viewport, character = nil)
  604.     @distance = 0
  605.     super(viewport, character)
  606.   end
  607.  
  608.   def update
  609.     super
  610.   end
  611.  
  612.   def update_balloon; end
  613.   def setup_new_effect; end
  614.  
  615.   def set_character_bitmap
  616.     if @character.reflect_sprite
  617.       self.bitmap = Cache.character(@character.reflect_sprite[0])
  618.     else
  619.       self.bitmap = Cache.character(@character_name)
  620.     end
  621.     self.mirror = true
  622.     self.opacity = 255
  623.     self.z = Galv_CEffects::REFLECT_Z
  624.  
  625.     sign = @character_name[/^[\!\$]./]
  626.     if sign && sign.include?('$')
  627.       @cw = bitmap.width / 3
  628.       @ch = bitmap.height / 4
  629.     else
  630.       @cw = bitmap.width / 12
  631.       @ch = bitmap.height / 8
  632.     end
  633.     self.ox = @cw / 2
  634.     self.oy = @ch
  635.   end
  636.  
  637.   def update_src_rect
  638.     if @character.reflect_sprite
  639.       index = @character.reflect_sprite[1]
  640.     else
  641.       index = @character.character_index
  642.     end
  643.     pattern = @character.pattern < 3 ? @character.pattern : 1
  644.     sx = (index % 4 * 3 + pattern) * @cw
  645.     sy = (index / 4 * 4 + (10 - @character.direction - 2) / 2) * @ch
  646.     self.src_rect.set(sx, sy, @cw, @ch)
  647.   end
  648.  
  649.   def get_mirror_y
  650.     20.times {|i|
  651.       if $game_map.region_id(@character.x, @character.y - i) == Galv_CEffects::MIRROR_REGION
  652.         @distance = (i - 1) * 0.05
  653.         @display = @character.y - i - $game_map.display_y + $game_map.height
  654.         self.opacity = 255
  655.         return (@character.y - i + 1 - $game_map.display_y) * 32 - i * 4
  656.       end
  657.     }
  658.     self.opacity = 0
  659.     return @ch
  660.   end
  661.  
  662.   def update_position
  663.     self.x = @character.screen_x
  664.     self.y = get_mirror_y - 6
  665.     self.zoom_x = 1 - @distance
  666.     self.zoom_y = 1 - @distance
  667.   end
  668.  
  669.   def update_other
  670.     self.blend_type = @character.blend_type
  671.     self.visible = !@character.transparent
  672.   end
  673. end # Sprite_Mirror < Sprite_Character
  674.  
  675.  
  676. #-------------------------------------------------------------------------------
  677. #  Sprite_Shadow
  678. #-------------------------------------------------------------------------------
  679.  
  680. class Sprite_Shadow < Sprite_Character
  681.   def initialize(viewport, character = nil, source)
  682.     @flicker = 0
  683.     @famount = 0
  684.     @aamount = 0
  685.     @source = source
  686.     super(viewport, character)
  687.   end
  688.  
  689.   def update_balloon; end
  690.   def setup_new_effect; end
  691.  
  692.   def update
  693.     super
  694.     update_bitmap
  695.     update_src_rect
  696.     update_position
  697.     update_other
  698.     update_facing
  699.   end
  700.  
  701.   def set_character_bitmap
  702.     self.bitmap = Cache.character(@character_name)
  703.  
  704.     self.color = Color.new(0, 0, 0, 255)
  705.     self.z = Galv_CEffects::SHADOW_Z
  706.     self.wave_amp = 1 if $game_map.shadow_options[2]
  707.     self.wave_speed = 1000
  708.  
  709.     sign = @character_name[/^[\!\$]./]
  710.     if sign && sign.include?('$')
  711.       @cw = bitmap.width / 3
  712.       @ch = bitmap.height / 4
  713.     else
  714.       @cw = bitmap.width / 12
  715.       @ch = bitmap.height / 8
  716.     end
  717.     self.ox = @cw / 2
  718.     self.oy = @ch
  719.   end
  720.  
  721.   def update_position
  722.     self.x = @character.screen_x
  723.     self.y = @character.screen_y - 10
  724.     get_angle
  725.   end
  726.  
  727.   def get_angle
  728.     x = $game_map.light_source[@source][0] - @character.real_x
  729.     y = $game_map.light_source[@source][1] - @character.real_y
  730.     self.opacity = $game_map.shadow_options[0] -
  731.       Math::sqrt(x * x + y * y) * $game_map.shadow_options[1]
  732.  
  733.     if x == 0 && y == 0 || self.opacity <= 0
  734.       self.opacity = 0
  735.     else
  736.       self.angle = Math::atan2(x, y) * 180 / Math::PI + @aamount
  737.     end
  738.   end
  739.  
  740.   def update_facing
  741.     if @character.y < $game_map.light_source[@source][1]
  742.       self.mirror = false
  743.     else
  744.       self.mirror = true
  745.     end
  746.   end
  747.  
  748.   def update_other
  749.     self.blend_type = @character.blend_type
  750.     self.visible = !@character.transparent
  751.   end
  752. end # Sprite_Shadow < Sprite_Character
  753.  
  754.  
  755. #-------------------------------------------------------------------------------
  756. #  Sprite_Icon
  757. #-------------------------------------------------------------------------------
  758.  
  759. class Sprite_Icon < Sprite_Character
  760.   def initialize(viewport, character = nil)
  761.     @icon_sprite ||= Sprite.new
  762.     @icon_sprite.bitmap ||= Cache.system("Iconset")
  763.     @icon = nil
  764.     super(viewport, character)
  765.   end
  766.  
  767.   def dispose
  768.     super
  769.     if @icon_sprite
  770.       @icon_sprite.dispose
  771.       @icon_sprite = nil
  772.     end
  773.   end
  774.  
  775.   def update
  776.     super
  777.     update_icon
  778.   end
  779.  
  780.   def update_icon
  781.     return if !@character.icon
  782.     draw_icon(@character.icon)
  783.   end
  784.  
  785.   def draw_icon(icon_index)
  786.     return if !@icon.nil?
  787.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  788.     @icon_sprite.src_rect  = rect
  789.     @icon = icon_index
  790.   end
  791.  
  792.   def update_position
  793.     @icon_sprite.x = @character.screen_x - 12
  794.     @icon_sprite.y = @character.screen_y + Galv_CEffects::ICON_OFFSET
  795.   end
  796.  
  797.   def update_other
  798.     self.blend_type = @character.blend_type
  799.     @icon_sprite.visible = !@character.transparent
  800.   end
  801. end # Sprite_Icon < Sprite_Character
  802.  
  803.  
  804. #-------------------------------------------------------------------------------
  805. #  Other Stuff
  806. #-------------------------------------------------------------------------------
  807.  
  808.  
  809. class Game_Character < Game_CharacterBase
  810.   attr_reader    :altitude
  811.   attr_accessor  :reflect
  812.   attr_accessor  :reflect_sprite
  813.   attr_accessor  :shadow
  814.   attr_accessor  :icon
  815.   attr_accessor  :icon_offset
  816. end
  817.  
  818.  
  819. class Game_Event < Game_Character
  820.   alias galv_reflect_ge_initialize initialize
  821.   def initialize(map_id, event)
  822.     @reflect = false
  823.     @shadow = false
  824.     @icon_offset = [0,0]
  825.     galv_reflect_ge_initialize(map_id, event)
  826.   end
  827. end # Game_Event < Game_Character
  828.  
  829.  
  830. class Game_Vehicle < Game_Character
  831.   attr_reader :map_id
  832.  
  833.   alias galv_reflect_gv_initialize initialize
  834.   def initialize(type)
  835.     @reflect = true
  836.     @shadow = true
  837.     @icon_offset = [0,0]
  838.     galv_reflect_gv_initialize(type)
  839.   end
  840. end # Game_Vehicle < Game_Character
  841.  
  842.  
  843. class Game_Follower < Game_Character
  844.   alias galv_reflect_gf_initialize initialize
  845.   def initialize(member_index, preceding_character)
  846.     galv_reflect_gf_initialize(member_index, preceding_character)
  847.     @reflect = true
  848.     @shadow = true
  849.   end
  850.  
  851.   alias galv_reflect_gf_refresh refresh
  852.   def refresh
  853.     galv_reflect_gf_refresh
  854.     return if actor.nil?
  855.     @reflect = actor.reflect
  856.     @reflect_sprite = actor.reflect_sprite
  857.     @icon = actor.icon
  858.     if SceneManager.scene_is?(Scene_Map)
  859.       SceneManager.scene.spriteset.refresh_effects
  860.     end
  861.   end
  862. end # Game_Follower < Game_Character
  863.  
  864.  
  865. class Game_Player < Game_Character
  866.   alias galv_reflect_gp_initialize initialize
  867.   def initialize
  868.     galv_reflect_gp_initialize
  869.     @reflect = true
  870.     @shadow = true
  871.   end
  872.  
  873.   alias galv_reflect_gp_refresh refresh
  874.   def refresh
  875.     galv_reflect_gp_refresh
  876.     @reflect = actor.reflect
  877.     @reflect_sprite = actor.reflect_sprite
  878.     @icon = actor.icon
  879.     if SceneManager.scene_is?(Scene_Map)
  880.       SceneManager.scene.spriteset.refresh_effects
  881.     end
  882.   end
  883. end # Game_Player < Game_Character
  884.  
  885.  
  886. class Scene_Map < Scene_Base
  887.   attr_accessor :spriteset
  888. end # Scene_Map
  889.  
  890.  
  891. class Game_Map
  892.   attr_accessor :char_effects
  893.   attr_accessor :light_source
  894.   attr_accessor :shadow_options
  895.   attr_accessor :reflect_options
  896.  
  897.   alias galv_reflect_game_map_initialize initialize
  898.   def initialize
  899.     @light_source = []
  900.     @shadow_options = [80,10,false]
  901.     @reflect_options = [0]
  902.     @char_effects = [false,false,false,false]
  903.     #[reflect,shadow,mirror,icon]
  904.     galv_reflect_game_map_initialize
  905.   end
  906.  
  907.  
  908.   alias galv_reflect_game_map_setup setup
  909.   def setup(map_id)
  910.     galv_reflect_game_map_setup(map_id)
  911.     reset_char_effects
  912.     do_all_chareffects
  913.     if SceneManager.scene_is?(Scene_Map)
  914.       SceneManager.scene.spriteset.refresh_effects
  915.     end
  916.   end
  917.  
  918.   def reset_char_effects
  919.     @light_source = []
  920.     @events.values.each { |e|
  921.       e.reflect = false
  922.       e.icon = nil }
  923.   end
  924. end # Game_Map
  925.  
  926.  
  927. class Game_Actor < Game_Battler
  928.   attr_accessor :reflect
  929.   attr_accessor :reflect_sprite
  930.   attr_accessor :icon
  931.  
  932.   alias galv_reflect_game_actor_initialize initialize
  933.   def initialize(actor_id)
  934.     galv_reflect_game_actor_initialize(actor_id)
  935.     @reflect = $data_actors[actor_id].reflect
  936.     @reflect_sprite = $data_actors[actor_id].reflect_sprite
  937.     @icon_offset = [0,0]
  938.   end
  939. end # Game_Actor < Game_Battler
  940.  
  941.  
  942. class RPG::Actor
  943.   def reflect_sprite
  944.     if @reflect_sprite.nil?
  945.       if @note =~ /<reflect_sprite:[ ](.*),(.*)>/i
  946.         @reflect_sprite = [$1.to_s,$2.to_i]
  947.       else
  948.         @reflect_sprite = nil
  949.       end
  950.     end
  951.     @reflect_sprite
  952.   end
  953.   def reflect
  954.     if @reflect.nil?
  955.       if @note =~ /<no_reflect>/i
  956.         @reflect = false
  957.       else
  958.         @reflect = true
  959.       end
  960.     end
  961.     @reflect
  962.   end
  963. end # RPG::Actor

RUBY 代码复制
  1. #==============================================================================
  2. # ■ 隐藏房间黑块
  3. #  by:VIPArcher
  4. #  -- 本脚本来自 [url]http://rm.66rpg.com[/url] 使用或转载请保留以上信息。
  5. #==============================================================================
  6. # 使用说明:
  7. #  · 指定遮罩块颜色可在设置的第一行注释上<color=Color.new(R,G,B)>
  8. #  · 在需要用黑块遮罩的地图上建一个事件,事件名为 "Black_Room"并且在该事件里注释上
  9. #  需要遮罩的范围矩形,例如 <6,4,10,17> 就为从地图坐标(6,4)开始到坐标(10,17)的矩形
  10. #  区域填充上黑色块遮罩掉,当玩家踏入这个矩形时遮罩块消失。查看坐标可以看地图编辑器
  11. #  右下角,把要遮罩的区域的左上角的坐标和右下角的坐标带入即可。
  12. #  · 每个遮罩区域可以指定角色踏入的矩形,规则同上,注释方法为在对应的矩形后面同一行
  13. #  注释,例如<6,4,10,17>,[6,4,10,18],未指定踏入区域时默认原矩形为踏入区域
  14. #  · 如需注释多个黑块房间请注意换行。
  15. #  · 需要用图片做为遮罩块,就像这样备注 <name=文件名 x:5 y:5>,[5,5,10,10]
  16. #   使用图片做为遮罩块必须设置踏入的矩形。文件放在"\Graphics\Parallaxes"文件夹下
  17. #==============================================================================
  18. $VIPArcherScript ||= {};$VIPArcherScript[:black_room] = 20150211
  19. #-------------------------------------------------------------------------------
  20. module VIPArcher end
  21. #==============================================================================
  22. # ★ 设定部分 ★
  23. #==============================================================================
  24. module VIPArcher::BlackRoom
  25.   Z = 999                        # 遮罩块的Z值
  26.   SW = 1                         # 该开关开启时遮罩块不可见
  27.   Edge = 16                      # 遮罩块边距留空的距离
  28.   Room_Color = Color.new(0,0,0)  # 默认遮罩块填充的颜色
  29.   Event_Name = 'Black_Room'      # 设置遮罩块的事件名
  30.   Opacity_Speed = 17             # 透明度变化的速度
  31. end
  32. #==============================================================================
  33. # ☆ 设定结束 ☆
  34. #==============================================================================
  35. class Sprite_BlackRoom < Sprite
  36.   include VIPArcher::BlackRoom
  37.   #--------------------------------------------------------------------------
  38.   # ● 初始化对象
  39.   #--------------------------------------------------------------------------
  40.   def initialize(rect,check_rect,color,viewport)
  41.     super(viewport)
  42.     @check_rect, @color = check_rect,color
  43.     if rect.is_a?(Rect)
  44.       self.x, self.y, self.z = rect.x * 32, rect.y * 32, Z
  45.       width, height = rect.width - rect.x + 1,rect.height - rect.y + 1
  46.       set_bitmap(width * 32,height * 32)
  47.     elsif rect.is_a?(Array)
  48.       self.x, self.y, self.z = rect[1] * 32, rect[2] * 32, Z
  49.       set_bitmap(rect[0])
  50.     end
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ● 设置Bitmap
  54.   #--------------------------------------------------------------------------
  55.   def set_bitmap(*args)
  56.     case args.size
  57.     when 1
  58.       self.bitmap = Cache.parallax(args[0])
  59.     when 2
  60.       self.bitmap = Bitmap.new(args[0], args[1])
  61.       rect = Rect.new(Edge, Edge, args[0] - Edge * 2, args[1] - Edge * 2)
  62.       self.bitmap.fill_rect(rect, @color)
  63.     end
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 释放
  67.   #--------------------------------------------------------------------------
  68.   def dispose
  69.     super
  70.     self.bitmap.dispose
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● 位置判定
  74.   #--------------------------------------------------------------------------
  75.   def character_pos?
  76.     $game_player.x > @check_rect.width  || $game_player.x <  @check_rect.x ||
  77.     $game_player.y > @check_rect.height || $game_player.y <  @check_rect.y
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 更新透明度
  81.   #--------------------------------------------------------------------------
  82.   def update_opacity
  83.     self.opacity += character_pos? ? Opacity_Speed : - Opacity_Speed
  84.     self.opacity = 0 if $game_switches[SW]
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 更新位置
  88.   #--------------------------------------------------------------------------
  89.   def update_position
  90.     self.ox = $game_map.display_x * 32
  91.     self.oy = $game_map.display_y * 32
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 更新画面
  95.   #--------------------------------------------------------------------------
  96.   def update
  97.     super
  98.     update_opacity
  99.     update_position
  100.   end
  101. end
  102. #-------------------------------------------------------------------------------
  103. class Spriteset_Map
  104.   include VIPArcher::BlackRoom
  105.   #--------------------------------------------------------------------------
  106.   # ● 生成黑色遮罩块
  107.   #--------------------------------------------------------------------------
  108.   alias black_room_create_characters create_characters
  109.   def create_characters
  110.     black_room_create_characters
  111.     room_sprite_dispose if @black_room_sprites
  112.     @black_room_sprites = []
  113.     $game_map.events.values.each do |event|
  114.       if event.instance_variable_get(:@event).name =~ /#{Event_Name}/i
  115.         return if event.list.nil?
  116.         event.list.each { |command| get_black_room_setup(command) }
  117.       end
  118.     end
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 获取遮罩块设置
  122.   #--------------------------------------------------------------------------
  123.   def get_black_room_setup(command)
  124.     return unless command.code == 108 or 408
  125.     command.parameters.each {|line|get_rect_setup(line); get_bitmap_setup(line)}
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● 备注文件名的设置
  129.   #--------------------------------------------------------------------------
  130.   def get_bitmap_setup(line)
  131.     if line =~ /<name\s*=\s*(\S+?)\s*x:\s*(\d+?)\s*y:\s*(\d+)>/i
  132.       rect = [$1,$2.to_i,$3.to_i]
  133.       if line =~ /\[(\d+.*?)\]/; x = $1.split(',')
  134.         check_rect = Rect.new(x[0].to_i,x[1].to_i,x[2].to_i,x[3].to_i)
  135.       end
  136.       sprite = Sprite_BlackRoom.new(rect,check_rect,@color,@viewport1)
  137.       sprite.opacity = 0 unless sprite.character_pos?
  138.       @black_room_sprites.push(sprite)
  139.     end
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 备注矩形的设置
  143.   #--------------------------------------------------------------------------
  144.   def get_rect_setup(line)
  145.     @color = eval($1) rescue Room_Color if line =~ /<color\s*=\s*(.*?)\s*>/i
  146.     @color = Room_Color unless @color.is_a?(Color)
  147.     if line =~ /<(\d+.*?)>/; x = $1.split(',')
  148.       check_rect = rect = Rect.new(x[0].to_i,x[1].to_i,x[2].to_i,x[3].to_i)
  149.       if line =~ /\[(\d+.*?)\]/; x = $1.split(',')
  150.         check_rect = Rect.new(x[0].to_i,x[1].to_i,x[2].to_i,x[3].to_i)
  151.       end
  152.       sprite = Sprite_BlackRoom.new(rect,check_rect,@color,@viewport1)
  153.       sprite.opacity = 0 unless sprite.character_pos?
  154.       @black_room_sprites.push(sprite)
  155.     end
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 释放
  159.   #--------------------------------------------------------------------------
  160.   alias black_room_dispose dispose
  161.   def dispose
  162.     black_room_dispose
  163.     room_sprite_dispose
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 释放遮罩块
  167.   #--------------------------------------------------------------------------
  168.   def room_sprite_dispose
  169.     @black_room_sprites.each {|sprite| sprite.dispose }
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 更新画面
  173.   #--------------------------------------------------------------------------
  174.   alias black_room_update update
  175.   def update
  176.     black_room_update
  177.     @black_room_sprites.each {|sprite| sprite.update }
  178.   end
  179. end

Project5.rar

1.43 MB, 下载次数: 29

Lv5.捕梦者

梦石
10
星屑
39592
在线时间
1920 小时
注册时间
2010-11-14
帖子
3320

R考场第七期纪念奖

2
发表于 2022-4-5 14:15:46 | 只看该作者
修复成功,把黑块脚本换成下面这个就行了。
隐藏房间黑块-兼容Galv行走图效果.zip (2.42 KB, 下载次数: 16)

评分

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

查看全部评分

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-24 00:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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