#------------------------------------------------------------------------------# # Galv's 行走图效果 #------------------------------------------------------------------------------# # For: RPGMAKER VX ACE # Version 2.1 #------------------------------------------------------------------------------# # 2014-01-16 - Version 2.1 - Fixed double balloon/animation bug with shadows # 2013-12-07 - Version 2.0 - Added comments to more easily add event effects # - Fixed shadow facing bug # 2013-02-24 - Version 1.9 - added z level option for reflection and shadows # 2013-02-23 - Version 1.8 - added multiple light sources for shadows # 2013-02-22 - Version 1.7 - bug fixes # 2013-02-22 - Version 1.6 - added icon effect # 2013-02-22 - Version 1.5 - fixed mirror bug on large maps # 2013-02-22 - Version 1.4 - added effects to vehicles # 2013-02-21 - Version 1.3 - fixed jump reflection and other minor tweaks # 2013-02-21 - Version 1.2 - bug with less than 4 actors (oops) # 2013-02-21 - Version 1.1 - updated flicker effect # 2013-02-21 - Version 1.0 - release #------------------------------------------------------------------------------# # 可以为地图上的事件、队友、角色添加一些特效. # 当前特效有: # # 影子 # 根据光源位置显示玩家和事件影子. # # 地面反射 # 可以显示水面倒影、地板反射,想做到和demo一样的效果,你需要自己去编辑. # # 墙壁反射 # 和反射很像,只是反射成像在墙壁上的镜子里. # #------------------------------------------------------------------------------# #------------------------------------------------------------------------------# # 新功能 - 事件页第一条插入注释 #------------------------------------------------------------------------------# # 在事件页的第一行使用以下注释,可以设定事件使用的效果,如果一个事件使用多种效 # 果,所有效果必须要放在同一行. # # <icon:id,x,y> # 在事件身上显示图标 (x 坐标偏移量,y 坐标偏移量) # <shadow> # 事件显示影子 # <reflect> # 事件显示反射 (包括地面和墙壁反射) # #------------------------------------------------------------------------------# # 例子: # <icon:1,0,0><shadow><reflect> # 事件显示1号图标、影子和反射 #------------------------------------------------------------------------------# #------------------------------------------------------------------------------# # 可用脚本: #------------------------------------------------------------------------------# # # char_effects(x,x,x,true/false) # #------------------------------------------------------------------------------# # # 启用或禁用当前地图中的单个/多个行走图效果. # # 将x替换为代表效果的数字 # # 0 = 地面反射 1 = 影子 2 = 墙壁反射 3 = 图标 #------------------------------------------------------------------------------# # EXAMPLES: # char_effects(0,true) # 启用地面反射效果 # char_effects(0,2,true) # 启用地面和墙壁反射效果 # char_effects(1,3,false) # 禁用影子和图标效果 #------------------------------------------------------------------------------# # # reflect_sprite(角色_id,文件名,索引) # 改变角色的反射图像(包括地面和墙壁反射) # # reflect_esprite(事件_id,文件名,索引) # 改变事件的反射图像(包括地面和墙壁反射) # # reflect_vsprite(载具_id,文件名,索引) # 改变载具的反射图像(包括地面和墙壁反射) # #------------------------------------------------------------------------------# # 自理: # reflect_sprite(1,"Actor2",2) # 1号角色使用行走图"Actor2"中2号索引的图像. # reflect_esprite(3,"Actor4",5) # 3号事件使用行走图"Actor4"中5号索引的图像. # reflect_vsprite(1,"Vehicle",5) # 船使用行走图"Vehicle"中5号索引的图像. #------------------------------------------------------------------------------# #------------------------------------------------------------------------------# # 启用/禁用单个/多个事件的脚本 #------------------------------------------------------------------------------# # # reflect(x,x,x,true/false) # 启用/禁用x号事件的某效果. x替换为事件id # shadow(x,x,x,true/false) # 可以使用 :all 代表所有事件 # icon(x,x,x,图标_id) # 图标_id = 0 时为无图标 # #------------------------------------------------------------------------------# # 例子: # reflect(14,17,3,1,true) # 启用14、17、3、1号事件的反射效果(包括地面和墙壁反射) # shadow(1,false) # 禁用1号事件的影子效果 # reflect(:all,true) # 启用所有事件的反射效果 # icon(1,2,3,4,38) # 1、2、3、4号事件头上显示38号图标 # # 注意: 为了防止卡顿,玩家进入某地图时,所有事件默认禁用影子和反射效果 # 你需要使用脚本或添加事件注释的方式手动指定事件要显示的效果. #------------------------------------------------------------------------------# #------------------------------------------------------------------------------# # 启用/禁用角色/载具效果的脚本 #------------------------------------------------------------------------------# # # actor_reflect(角色_id,true/false) # 角色和载具默认启用反射和影子效果 # actor_shadow(角色_id,true/false) # 使用脚本改变其显示设定后,会永久性生效 # actor_icon(角色_id,图标_id) # 不会因为切换地图而恢复默认设定. # # v_reflect(x,x,x,true/false) # v_shadow(x,x,x,true/false) # v_icon(x,x,x,图标_id) # #------------------------------------------------------------------------------# #------------------------------------------------------------------------------# # 影子设定的脚本 #------------------------------------------------------------------------------# # # shadow_source(x,y,光源id) # 设定光源的x、y坐标,和使用的光源id # # 场所移动后设定会被重置. # # shadow_source(事件_id,光源id) # 光源在某个事件的位置上. # # 当光源移动时需要事件的触发条件为“并行处理” # # shadow_options(强度,淡出,明灭效果) # 下面有说明 # # # 强度 = 站在光源旁边时,影子的不透明度 (255 = 全黑) # # 淡出 = 玩家离光源越远,影子不透明度减小的值. # # 明灭效果 = true 或 false. 模拟火堆的明灭闪烁效果. # #------------------------------------------------------------------------------# # 例子: # shadow_options(80,10,false) # 默认设定:强度=80、淡出=10、不显示明灭效果. #------------------------------------------------------------------------------# #------------------------------------------------------------------------------# # 反射设定的脚本 #------------------------------------------------------------------------------# # # reflect_options(波动强度) # # # 波动强度 = 波动强度的大小. 0 = 不显示波动效果 # #------------------------------------------------------------------------------# # 例子: # reflect_options(1) # 波动强度 = 1 #------------------------------------------------------------------------------# #------------------------------------------------------------------------------# # 角色备注 #------------------------------------------------------------------------------# # # <no_reflect> # 该角色不显示反射 (当然是吸血鬼啦!) # # <reflect_sprite: 文件名,索引> # 设定角色的反射图像和索引 # #------------------------------------------------------------------------------# # 例子: # <reflect_sprite: Actor2,0> # <reflect_sprite: Actor3,7> #------------------------------------------------------------------------------# ($imported ||= {})["Galv_Character_Effects"] = true module Galv_CEffects #------------------------------------------------------------------------------# # 脚本设定部分 #------------------------------------------------------------------------------# MIRROR_REGION = 1 # 墙壁反射的区域id. 在代表墙壁的地图(必须是空白图快) # 中画该id的区域 # 然后可以使用远景图或地图图层显示反射的地图区域 ICON_OFFSET = -60 # 图标离行走图多少像素的高度(Y坐标偏移量) REFLECT_Z = -10 # 反射图像的Z坐标 SHADOW_Z = 0 # 影子图像的Z坐标 #------------------------------------------------------------------------------# # END SETUP OPTIONS #------------------------------------------------------------------------------# end class Game_Map def do_icons(refresh = true) @events.values.each { |e| next if !e.list if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<icon:(.*),(.*),(.*)>/ e.icon = $1.to_i e.icon_offset = [$2.to_i,$3.to_i] else e.icon = 0 e.icon_offset = [0,0] end } SceneManager.scene.spriteset.refresh_effects if refresh end def do_shadows(refresh = true) @events.values.each { |e| next if !e.list if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<shadow>/ e.shadow = true else e.shadow = false end } SceneManager.scene.spriteset.refresh_effects if refresh end def do_reflects(refresh = true) @events.values.each { |e| next if !e.list if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<reflect>/ e.reflect = true else e.reflect = false end } SceneManager.scene.spriteset.refresh_effects if refresh end def do_all_chareffects do_icons(false) do_shadows(false) do_reflects(false) end end # Game_Map class Game_Interpreter def remove_icon icon(@event_id,0) end #-----------------------------------# # REFLECTIONS #-----------------------------------# # Add/Remove Reflections from selected events def reflect(*args,status) char_ids = [*args] if char_ids == [:all] $game_map.events.values.each { |e| e.reflect = status } else char_ids.each {|c| $game_map.events[c].reflect = status } end SceneManager.scene.spriteset.refresh_effects end # Change forever actor's reflect status def actor_reflect(actor_id,status) $game_actors[actor_id].reflect = status $game_player.refresh end # Change forever vehicle's reflect status def v_reflect(*args,status) char_ids = [*args] if char_ids == [:all] $game_map.vehicles.each { |v| v.reflect = status } else char_ids.each { |v| $game_map.vehicles[v].reflect = status } end SceneManager.scene.spriteset.refresh_effects end def reflect_options(*args) $game_map.reflect_options = [*args] SceneManager.scene.spriteset.refresh_effects end # Actor reflect sprite change def reflect_sprite(actor_id,filename,pos) $game_actors[actor_id].reflect_sprite = [filename,pos] $game_player.refresh end # Event reflect sprite change def reflect_esprite(event_id,filename,pos) $game_map.events[event_id].reflect_sprite = [filename,pos] $game_map.events[event_id].reflect = true SceneManager.scene.spriteset.refresh_characters end # Vehicle reflect sprite change def reflect_vsprite(v_id,filename,pos) $game_map.vehicles[v_id].reflect_sprite = [filename,pos] SceneManager.scene.spriteset.refresh_characters end #-----------------------------------# # SHADOWS #-----------------------------------# # Add/Remove Shadows from selected characters def shadow(*args,status) char_ids = [*args] if char_ids == [:all] $game_map.events.values.each { |e| e.shadow = status } else char_ids.each {|c| $game_map.events[c].shadow = status } end SceneManager.scene.spriteset.refresh_effects end # Change player and follower shadows def actor_shadows(status) $game_player.shadow = status $game_player.followers.each { |f| f.shadow = status } SceneManager.scene.spriteset.refresh_effects end # Change vehicle's shadow status def v_shadow(*args,status) char_ids = [*args] if char_ids == [:all] $game_map.vehicles.each { |v| v.shadow = status } else char_ids.each { |v| $game_map.vehicles[v].shadow = status } end SceneManager.scene.spriteset.refresh_effects end def shadow_options(*args) $game_map.shadow_options = [*args] SceneManager.scene.spriteset.refresh_effects end def shadow_source(*args,shad_id) shadsource = [*args] if shadsource.count == 1 $game_map.light_source[shad_id] = [$game_map.events[shadsource[0]].real_x, $game_map.events[shadsource[0]].real_y] elsif shadsource.count > 1 $game_map.light_source[shad_id] = shadsource else $game_map.light_source = [] end end #-----------------------------------# # ICONS #-----------------------------------# # Add/Remove Icons from selected events def icon(*args,icon_id) char_ids = [*args] if char_ids == [:all] $game_map.events.values.each { |e| if e.icon <= 0 e.icon = nil else e.icon = icon_id end } else char_ids.each {|c| $game_map.events[c].icon = icon_id } end SceneManager.scene.spriteset.refresh_effects end # Change forever actor's icon def actor_icon(actor_id,icon_id) $game_actors[actor_id].icon = icon_id $game_player.refresh end # Change forever vehicle's icon def v_icon(*args,icon_id) char_ids = [*args] if char_ids == [:all] $game_map.vehicles.each { |v| v.icon = icon_id } else char_ids.each { |v| $game_map.vehicles[v].icon = icon_id } end SceneManager.scene.spriteset.refresh_effects end #-----------------------------------# # GENERAL #-----------------------------------# # Turn on/off effects # 0 = reflect # 1 = shadow # 2 = mirror # 3 = icon def char_effects(*args,status) [*args].each { |e| $game_map.char_effects[e] = status } SceneManager.scene.spriteset.refresh_effects end end # Game_Interpreter #------------------------------------------------------------------------------- # Spriteset_Map #------------------------------------------------------------------------------- class Spriteset_Map alias galv_reflect_sm_initialize initialize def initialize create_effects galv_reflect_sm_initialize refresh_characters end alias galv_reflect_sm_refresh_characters refresh_characters def refresh_characters galv_reflect_sm_refresh_characters create_effects end def refresh_effects dispose_effects create_effects end def create_effects @shadow_sprites = [] @reflect_sprites = [] @mirror_sprites = [] @icon_sprites = [] # Do reflections if $game_map.char_effects[0] $game_map.events.values.each { |e| @reflect_sprites.push(Sprite_Reflect.new(@viewport1, e)) if e.reflect } $game_player.followers.each { |f| @reflect_sprites.push(Sprite_Reflect.new(@viewport1, f)) if f.reflect } if $game_player.reflect @reflect_sprites.push(Sprite_Reflect.new(@viewport1, $game_player)) end $game_map.vehicles.each { |v| @reflect_sprites.push(Sprite_Reflect.new(@viewport1, v)) if v.reflect } end # Do mirrors if $game_map.char_effects[2] $game_map.events.values.each { |e| @mirror_sprites.push(Sprite_Mirror.new(@viewport1, e)) if e.reflect } $game_player.followers.each { |f| @mirror_sprites.push(Sprite_Mirror.new(@viewport1, f)) if f.reflect } if $game_player.reflect @mirror_sprites.push(Sprite_Mirror.new(@viewport1, $game_player)) end $game_map.vehicles.each { |v| @mirror_sprites.push(Sprite_Mirror.new(@viewport1, v)) if v.reflect } end # Do Shadows if $game_map.char_effects[1] return if $game_map.light_source.empty? $game_map.light_source.count.times { |s| $game_map.events.values.each { |e| @shadow_sprites.push(Sprite_Shadow.new(@viewport1, e, s)) if e.shadow } $game_player.followers.each { |f| @shadow_sprites.push(Sprite_Shadow.new(@viewport1, f, s)) if f.shadow } if $game_player.shadow @shadow_sprites.push(Sprite_Shadow.new(@viewport1, $game_player, s)) end $game_map.vehicles.each { |v| @shadow_sprites.push(Sprite_Shadow.new(@viewport1, v, s)) if v.shadow } } end # Do icons if $game_map.char_effects[3] $game_map.events.values.each { |e| @icon_sprites.push(Sprite_Icon.new(@viewport1, e)) if e.icon } $game_player.followers.each { |f| @icon_sprites.push(Sprite_Icon.new(@viewport1, f)) if f.icon } if $game_player.icon @icon_sprites.push(Sprite_Icon.new(@viewport1, $game_player)) end $game_map.vehicles.each { |v| @icon_sprites.push(Sprite_Icon.new(@viewport1, v)) if v.icon } end end alias galv_reflect_sm_update update def update galv_reflect_sm_update @reflect_sprites.each {|s| s.update} if $game_map.char_effects[0] @mirror_sprites.each {|s| s.update} if $game_map.char_effects[2] @shadow_sprites.each {|s| s.update} if $game_map.char_effects[1] @icon_sprites.each {|s| s.update} if $game_map.char_effects[3] end alias galv_reflect_sm_dispose_characters dispose_characters def dispose_characters galv_reflect_sm_dispose_characters dispose_effects end def dispose_effects @reflect_sprites.each {|s| s.dispose} @shadow_sprites.each {|s| s.dispose} @mirror_sprites.each {|s| s.dispose} @icon_sprites.each {|s| s.dispose} end end # Spriteset_Map #------------------------------------------------------------------------------- # Sprite_Reflect #------------------------------------------------------------------------------- class Sprite_Reflect < Sprite_Character def initialize(viewport, character = nil) super(viewport, character) end def update super end def update_balloon; end def setup_new_effect; end def set_character_bitmap if @character.reflect_sprite self.bitmap = Cache.character(@character.reflect_sprite[0]) else self.bitmap = Cache.character(@character_name) end self.mirror = true self.angle = 180 self.opacity = 220 self.z = Galv_CEffects::REFLECT_Z self.wave_amp = $game_map.reflect_options[0] sign = @character_name[/^[\!\$]./] if sign && sign.include?('$') @cw = bitmap.width / 3 @ch = bitmap.height / 4 else @cw = bitmap.width / 12 @ch = bitmap.height / 8 end self.ox = @cw / 2 self.oy = @ch end def update_position self.x = @character.screen_x jump = @character.jumping? ? @character.jump_height * 2 : 0 alt = @character.altitude ? @character.altitude * 2 : 0 self.y = @character.screen_y - 3 + jump + alt end def update_other self.blend_type = @character.blend_type self.visible = !@character.transparent end def update_src_rect if @character.reflect_sprite index = @character.reflect_sprite[1] else index = @character.character_index end pattern = @character.pattern < 3 ? @character.pattern : 1 sx = (index % 4 * 3 + pattern) * @cw sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch self.src_rect.set(sx, sy, @cw, @ch) end end # Sprite_Reflect < Sprite_Character #------------------------------------------------------------------------------- # Sprite_Mirror #------------------------------------------------------------------------------- class Sprite_Mirror < Sprite_Character def initialize(viewport, character = nil) @distance = 0 super(viewport, character) end def update super end def update_balloon; end def setup_new_effect; end def set_character_bitmap if @character.reflect_sprite self.bitmap = Cache.character(@character.reflect_sprite[0]) else self.bitmap = Cache.character(@character_name) end self.mirror = true self.opacity = 255 self.z = Galv_CEffects::REFLECT_Z sign = @character_name[/^[\!\$]./] if sign && sign.include?('$') @cw = bitmap.width / 3 @ch = bitmap.height / 4 else @cw = bitmap.width / 12 @ch = bitmap.height / 8 end self.ox = @cw / 2 self.oy = @ch end def update_src_rect if @character.reflect_sprite index = @character.reflect_sprite[1] else index = @character.character_index end pattern = @character.pattern < 3 ? @character.pattern : 1 sx = (index % 4 * 3 + pattern) * @cw sy = (index / 4 * 4 + (10 - @character.direction - 2) / 2) * @ch self.src_rect.set(sx, sy, @cw, @ch) end def get_mirror_y 20.times {|i| if $game_map.region_id(@character.x, @character.y - i) == Galv_CEffects::MIRROR_REGION @distance = (i - 1) * 0.05 @display = @character.y - i - $game_map.display_y + $game_map.height self.opacity = 255 return (@character.y - i + 1 - $game_map.display_y) * 32 - i * 4 end } self.opacity = 0 return @ch end def update_position self.x = @character.screen_x self.y = get_mirror_y - 6 self.zoom_x = 1 - @distance self.zoom_y = 1 - @distance end def update_other self.blend_type = @character.blend_type self.visible = !@character.transparent end end # Sprite_Mirror < Sprite_Character #------------------------------------------------------------------------------- # Sprite_Shadow #------------------------------------------------------------------------------- class Sprite_Shadow < Sprite_Character def initialize(viewport, character = nil, source) @flicker = 0 @famount = 0 @aamount = 0 @source = source super(viewport, character) end def update_balloon; end def setup_new_effect; end def update super update_bitmap update_src_rect update_position update_other update_facing end def set_character_bitmap self.bitmap = Cache.character(@character_name) self.color = Color.new(0, 0, 0, 255) self.z = Galv_CEffects::SHADOW_Z self.wave_amp = 1 if $game_map.shadow_options[2] self.wave_speed = 1000 sign = @character_name[/^[\!\$]./] if sign && sign.include?('$') @cw = bitmap.width / 3 @ch = bitmap.height / 4 else @cw = bitmap.width / 12 @ch = bitmap.height / 8 end self.ox = @cw / 2 self.oy = @ch end def update_position self.x = @character.screen_x self.y = @character.screen_y - 10 get_angle end def get_angle x = $game_map.light_source[@source][0] - @character.real_x y = $game_map.light_source[@source][1] - @character.real_y self.opacity = $game_map.shadow_options[0] - Math::sqrt(x * x + y * y) * $game_map.shadow_options[1] if x == 0 && y == 0 || self.opacity <= 0 self.opacity = 0 else self.angle = Math::atan2(x, y) * 180 / Math::PI + @aamount end end def update_facing if @character.y < $game_map.light_source[@source][1] self.mirror = false else self.mirror = true end end def update_other self.blend_type = @character.blend_type self.visible = !@character.transparent end end # Sprite_Shadow < Sprite_Character #------------------------------------------------------------------------------- # Sprite_Icon #------------------------------------------------------------------------------- class Sprite_Icon < Sprite_Character def initialize(viewport, character = nil) @icon_sprite ||= Sprite.new @icon_sprite.bitmap ||= Cache.system("Iconset") @icon = nil super(viewport, character) end def dispose super if @icon_sprite @icon_sprite.dispose @icon_sprite = nil end end def update super update_icon end def update_icon return if !@character.icon draw_icon(@character.icon) end def draw_icon(icon_index) return if !@icon.nil? rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) @icon_sprite.src_rect = rect @icon = icon_index end def update_position @icon_sprite.x = @character.screen_x - 12 @icon_sprite.y = @character.screen_y + Galv_CEffects::ICON_OFFSET end def update_other self.blend_type = @character.blend_type @icon_sprite.visible = !@character.transparent end end # Sprite_Icon < Sprite_Character #------------------------------------------------------------------------------- # Other Stuff #------------------------------------------------------------------------------- class Game_Character < Game_CharacterBase attr_reader :altitude attr_accessor :reflect attr_accessor :reflect_sprite attr_accessor :shadow attr_accessor :icon attr_accessor :icon_offset end class Game_Event < Game_Character alias galv_reflect_ge_initialize initialize def initialize(map_id, event) @reflect = false @shadow = false @icon_offset = [0,0] galv_reflect_ge_initialize(map_id, event) end end # Game_Event < Game_Character class Game_Vehicle < Game_Character attr_reader :map_id alias galv_reflect_gv_initialize initialize def initialize(type) @reflect = true @shadow = true @icon_offset = [0,0] galv_reflect_gv_initialize(type) end end # Game_Vehicle < Game_Character class Game_Follower < Game_Character alias galv_reflect_gf_initialize initialize def initialize(member_index, preceding_character) galv_reflect_gf_initialize(member_index, preceding_character) @reflect = true @shadow = true end alias galv_reflect_gf_refresh refresh def refresh galv_reflect_gf_refresh return if actor.nil? @reflect = actor.reflect @reflect_sprite = actor.reflect_sprite @icon = actor.icon if SceneManager.scene_is?(Scene_Map) SceneManager.scene.spriteset.refresh_effects end end end # Game_Follower < Game_Character class Game_Player < Game_Character alias galv_reflect_gp_initialize initialize def initialize galv_reflect_gp_initialize @reflect = true @shadow = true end alias galv_reflect_gp_refresh refresh def refresh galv_reflect_gp_refresh @reflect = actor.reflect @reflect_sprite = actor.reflect_sprite @icon = actor.icon if SceneManager.scene_is?(Scene_Map) SceneManager.scene.spriteset.refresh_effects end end end # Game_Player < Game_Character class Scene_Map < Scene_Base attr_accessor :spriteset end # Scene_Map class Game_Map attr_accessor :char_effects attr_accessor :light_source attr_accessor :shadow_options attr_accessor :reflect_options alias galv_reflect_game_map_initialize initialize def initialize @light_source = [] @shadow_options = [80,10,false] @reflect_options = [0] @char_effects = [false,false,false,false] #[reflect,shadow,mirror,icon] galv_reflect_game_map_initialize end alias galv_reflect_game_map_setup setup def setup(map_id) galv_reflect_game_map_setup(map_id) reset_char_effects do_all_chareffects if SceneManager.scene_is?(Scene_Map) SceneManager.scene.spriteset.refresh_effects end end def reset_char_effects @light_source = [] @events.values.each { |e| e.reflect = false e.icon = nil } end end # Game_Map class Game_Actor < Game_Battler attr_accessor :reflect attr_accessor :reflect_sprite attr_accessor :icon alias galv_reflect_game_actor_initialize initialize def initialize(actor_id) galv_reflect_game_actor_initialize(actor_id) @reflect = $data_actors[actor_id].reflect @reflect_sprite = $data_actors[actor_id].reflect_sprite @icon_offset = [0,0] end end # Game_Actor < Game_Battler class RPG::Actor def reflect_sprite if @reflect_sprite.nil? if @note =~ /<reflect_sprite:[ ](.*),(.*)>/i @reflect_sprite = [$1.to_s,$2.to_i] else @reflect_sprite = nil end end @reflect_sprite end def reflect if @reflect.nil? if @note =~ /<no_reflect>/i @reflect = false else @reflect = true end end @reflect end end # RPG::Actor
#============================================================================== # ■ 隐藏房间黑块 # by:VIPArcher # -- 本脚本来自 [url]http://rm.66rpg.com[/url] 使用或转载请保留以上信息。 #============================================================================== # 使用说明: # · 指定遮罩块颜色可在设置的第一行注释上<color=Color.new(R,G,B)> # · 在需要用黑块遮罩的地图上建一个事件,事件名为 "Black_Room"并且在该事件里注释上 # 需要遮罩的范围矩形,例如 <6,4,10,17> 就为从地图坐标(6,4)开始到坐标(10,17)的矩形 # 区域填充上黑色块遮罩掉,当玩家踏入这个矩形时遮罩块消失。查看坐标可以看地图编辑器 # 右下角,把要遮罩的区域的左上角的坐标和右下角的坐标带入即可。 # · 每个遮罩区域可以指定角色踏入的矩形,规则同上,注释方法为在对应的矩形后面同一行 # 注释,例如<6,4,10,17>,[6,4,10,18],未指定踏入区域时默认原矩形为踏入区域 # · 如需注释多个黑块房间请注意换行。 # · 需要用图片做为遮罩块,就像这样备注 <name=文件名 x:5 y:5>,[5,5,10,10] # 使用图片做为遮罩块必须设置踏入的矩形。文件放在"\Graphics\Parallaxes"文件夹下 #============================================================================== $VIPArcherScript ||= {};$VIPArcherScript[:black_room] = 20150211 #------------------------------------------------------------------------------- module VIPArcher end #============================================================================== # ★ 设定部分 ★ #============================================================================== module VIPArcher::BlackRoom Z = 999 # 遮罩块的Z值 SW = 1 # 该开关开启时遮罩块不可见 Edge = 16 # 遮罩块边距留空的距离 Room_Color = Color.new(0,0,0) # 默认遮罩块填充的颜色 Event_Name = 'Black_Room' # 设置遮罩块的事件名 Opacity_Speed = 17 # 透明度变化的速度 end #============================================================================== # ☆ 设定结束 ☆ #============================================================================== class Sprite_BlackRoom < Sprite include VIPArcher::BlackRoom #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize(rect,check_rect,color,viewport) super(viewport) @check_rect, @color = check_rect,color if rect.is_a?(Rect) self.x, self.y, self.z = rect.x * 32, rect.y * 32, Z width, height = rect.width - rect.x + 1,rect.height - rect.y + 1 set_bitmap(width * 32,height * 32) elsif rect.is_a?(Array) self.x, self.y, self.z = rect[1] * 32, rect[2] * 32, Z set_bitmap(rect[0]) end end #-------------------------------------------------------------------------- # ● 设置Bitmap #-------------------------------------------------------------------------- def set_bitmap(*args) case args.size when 1 self.bitmap = Cache.parallax(args[0]) when 2 self.bitmap = Bitmap.new(args[0], args[1]) rect = Rect.new(Edge, Edge, args[0] - Edge * 2, args[1] - Edge * 2) self.bitmap.fill_rect(rect, @color) end end #-------------------------------------------------------------------------- # ● 释放 #-------------------------------------------------------------------------- def dispose super self.bitmap.dispose end #-------------------------------------------------------------------------- # ● 位置判定 #-------------------------------------------------------------------------- def character_pos? $game_player.x > @check_rect.width || $game_player.x < @check_rect.x || $game_player.y > @check_rect.height || $game_player.y < @check_rect.y end #-------------------------------------------------------------------------- # ● 更新透明度 #-------------------------------------------------------------------------- def update_opacity self.opacity += character_pos? ? Opacity_Speed : - Opacity_Speed self.opacity = 0 if $game_switches[SW] end #-------------------------------------------------------------------------- # ● 更新位置 #-------------------------------------------------------------------------- def update_position self.ox = $game_map.display_x * 32 self.oy = $game_map.display_y * 32 end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- def update super update_opacity update_position end end #------------------------------------------------------------------------------- class Spriteset_Map include VIPArcher::BlackRoom #-------------------------------------------------------------------------- # ● 生成黑色遮罩块 #-------------------------------------------------------------------------- alias black_room_create_characters create_characters def create_characters black_room_create_characters room_sprite_dispose if @black_room_sprites @black_room_sprites = [] $game_map.events.values.each do |event| if event.instance_variable_get(:@event).name =~ /#{Event_Name}/i return if event.list.nil? event.list.each { |command| get_black_room_setup(command) } end end end #-------------------------------------------------------------------------- # ● 获取遮罩块设置 #-------------------------------------------------------------------------- def get_black_room_setup(command) return unless command.code == 108 or 408 command.parameters.each {|line|get_rect_setup(line); get_bitmap_setup(line)} end #-------------------------------------------------------------------------- # ● 备注文件名的设置 #-------------------------------------------------------------------------- def get_bitmap_setup(line) if line =~ /<name\s*=\s*(\S+?)\s*x:\s*(\d+?)\s*y:\s*(\d+)>/i rect = [$1,$2.to_i,$3.to_i] if line =~ /\[(\d+.*?)\]/; x = $1.split(',') check_rect = Rect.new(x[0].to_i,x[1].to_i,x[2].to_i,x[3].to_i) end sprite = Sprite_BlackRoom.new(rect,check_rect,@color,@viewport1) sprite.opacity = 0 unless sprite.character_pos? @black_room_sprites.push(sprite) end end #-------------------------------------------------------------------------- # ● 备注矩形的设置 #-------------------------------------------------------------------------- def get_rect_setup(line) @color = eval($1) rescue Room_Color if line =~ /<color\s*=\s*(.*?)\s*>/i @color = Room_Color unless @color.is_a?(Color) if line =~ /<(\d+.*?)>/; x = $1.split(',') check_rect = rect = Rect.new(x[0].to_i,x[1].to_i,x[2].to_i,x[3].to_i) if line =~ /\[(\d+.*?)\]/; x = $1.split(',') check_rect = Rect.new(x[0].to_i,x[1].to_i,x[2].to_i,x[3].to_i) end sprite = Sprite_BlackRoom.new(rect,check_rect,@color,@viewport1) sprite.opacity = 0 unless sprite.character_pos? @black_room_sprites.push(sprite) end end #-------------------------------------------------------------------------- # ● 释放 #-------------------------------------------------------------------------- alias black_room_dispose dispose def dispose black_room_dispose room_sprite_dispose end #-------------------------------------------------------------------------- # ● 释放遮罩块 #-------------------------------------------------------------------------- def room_sprite_dispose @black_room_sprites.each {|sprite| sprite.dispose } end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- alias black_room_update update def update black_room_update @black_room_sprites.each {|sprite| sprite.update } end end
1.43 MB, 下载次数: 29
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |