赞 47  
 
VIP 0 
 
好人卡 2 
 
积分 145  
经验 67210 
 
最后登录 2025-10-30 
 
在线时间 3980 小时 
 
 
 
Lv4.逐梦者 
	梦石 0  星屑 14510  
        在线时间 3980 小时 
        注册时间 2013-7-18 
        帖子 2377  
 
 
	
加入我们,或者,欢迎回来。 您需要 登录  才可以下载或查看,没有帐号?注册会员  
 
x 
 
 本帖最后由 y967 于 2015-12-29 20:26 编辑  =begin 
  HN_Light version 1.0.1.0 for VX Ace 
        by 半生 
 
  
  要HN_RG_BITMAP(ver 0.1.2.1以降) 
  
2012/01/08 ver 1.0.1.2 
 队列歩行の仲间に対応 
 
2015/04/25 Xp移植 
  By RyanBern 
  
=end 
 
# ----- 在这里设定----- 
module  HN_Light
  # 简略化0:(精细)~2:(粗暴,负荷轻) 
  SIMPLIFY = 1 
 
  # 表示黑暗处的不透明度,数值为0-255,越大则不可见度越高 
  DARK_OPACITY = 190 
 
  # 玩家的烛光类型使用的变量号码 
  PLAYER_LIGHT_TYPE = 13 
 
  # 黑暗判断上使用的开关 
  DARK_SWITCH = 73 
 
  # 烛光事件识别用的正规表达式 
  REGEX_LIGHT = /@LIGHT( \d+) /
 
  # 烛光图像的目录 
  LIGHT_IMG_DIR = "Graphics/Pictures/" 
 
  # 烛光Bitmap设定 
  LIGHTS = [  
  # [文件名  ,格栅数, 放大率,  Y偏移值, 色相] 
    [ "light6" ,     1 ,    5.0 ,        0 ,    0 ] ,
    [ "light6" ,     1 ,    7.5 ,        0 ,    0 ] ,
    [ "light6" ,     1 ,    10.0 ,        0 ,    0 ] ,
    [ "light5" ,     1 ,    12.0 ,      -16 ,    0 ] ,
    [ "light5" ,     1 ,    5.0 ,        0 ,    0 ] ,
    [ "light5" ,     1 ,    15.0 ,        0 ,    0 ] ,
    [ "light7" ,     1 ,    3.0 ,      -16 ,    0 ] ,
    [ "light8" ,     1 ,    0.5 ,        0 ,    0 ] ,
    [ "light9" ,     1 ,    2.0 ,        0 ,    0 ] ,
  ] 
end 
#  ----- 在这里设定 ----- 
 
module  HN_Light
  # 事件mix-in用 
  module  LightEvent
    attr_reader :light_type 
    def  initialize
      super ( ) 
      @light_type  = 0 
    end 
 
    def  check_light
      @light_type  = 0 
      return  if  @list .nil ?
      @list .each  do  |command|
        break  if  @light_type  > 0 
        if  command.code  == 108  or  command.code  == 408 
          command.parameters .each  do  |line|
            if  line =~ REGEX_LIGHT
              @light_type  = $1 .to_i 
              break 
            end 
          end 
        end 
      end  # END @list.each 
    end 
 
  end  # END module LightEvent 
 
 
  class  Light
    attr_reader :bitmap 
    attr_reader :cells 
    attr_reader :width 
    attr_reader :height 
    attr_reader :ox 
    attr_reader :oy 
    def  initialize( light_type, s_zoom = 1 ) 
      light = LIGHTS[ light_type - 1 ] 
      if  light.nil ?
        # 本来不应该来这里 
        @bitmap  = Bitmap.new ( 32 , 32 ) 
        @cels  = 1 
        @zoom  = 1.0 
        @oy  = 16 
        @ox  = 16 
        @width   = 32 
        @height  = 32 
      else 
        @bitmap  = Bitmap.new ( LIGHT_IMG_DIR + light[ 0 ] ) 
        @bitmap .invert ( ) 
        @cells  = light[ 1 ] .to_i 
        @cells  = 1  if  ( @cells < 1  or  @cells  > @bitmap .width ) 
        @zoom  = light[ 2 ] .to_f 
        @zoom  = 1.0  if  @zoom  <= 0.0 
        @zoom  /= s_zoom
        @width   = @bitmap .width  / @cells 
        @height  = @bitmap .height 
 
        # 缩放处理 
        if  @zoom  != 1.0 
          new_width  = ( @width * @zoom ) .round 
          new_height = ( @height * @zoom ) .round 
          if  new_width * new_height < 1 
            @zoom  = 1.0 
          else 
            @width  = new_width
            @height  = new_height
            new_bitmap = Bitmap.new ( @width * @cells , @height ) 
            new_bitmap.stretch_blt ( new_bitmap.rect ,@bitmap, @bitmap .rect ) 
            @bitmap .dispose 
            @bitmap  = new_bitmap
          end 
        end 
        @ox  = @width  / 2 
        @oy  = @height  / 2  - light[ 3 ] .to_i  / s_zoom
 
        # 色相変换 
        if  (  ( hue = light[ 4 ] .to_i )  != 0 ) 
          @bitmap .hue_change ( hue) 
        end 
      end 
    end  # End def initialize 
 
    # 色调转换 
    def  dispose
      @bitmap .dispose 
      @bitmap  = nil 
    end 
  end 
 
end 
 
class  Game_Event
  include  HN_Light::LightEvent 
  alias  :_hn_light__setup  :refresh  unless  method_defined?( :_hn_light__setup ) 
  def  refresh
    _hn_light__setup
    check_light( ) 
  end 
end 
 
class  Game_Player
  def  light_type
    return  $game_variables [ HN_Light::PLAYER_LIGHT_TYPE ] 
  end 
end 
 
class  Game_Map
  attr_reader :light_events 
 
  # 更新烛光事件列表 
  def  refresh_lights
    @light_events  = [ ] 
    @events .values .each  do  |event|
      if  ( event.light_type  > 0 ) 
        @light_events .push ( event) 
      end 
    end 
  end 
 
  alias  :_hn_light__setup_events  :setup  unless  method_defined?( :_hn_light__setup_events ) 
  def  setup( map_id) 
    _hn_light__setup_events( map_id) 
    refresh_lights( ) 
  end 
 
  alias  :_hn_light__refresh  :refresh  unless  method_defined?( :_hn_light__refresh ) 
  def  refresh
    _hn_light__refresh( ) 
    refresh_lights( ) 
  end 
end 
 
class  Sprite_Dark < Sprite
  @@base_color = Color.new ( 255 ,255 ,255 ,HN_Light::DARK_OPACITY ) 
 
  def  initialize( viewport = nil ) 
    super ( viewport) 
    @width  = 640 
    @height  = 480 
 
    case  HN_Light::SIMPLIFY 
    when  1 
      @zoom  = 2 
    when  2 
      @zoom  = 4 
    else 
      @zoom  = 1 
    end 
    @width  /= @zoom 
    @height  /= @zoom 
    self .zoom_x  = @zoom .to_f 
    self .zoom_y  = @zoom .to_f 
 
    self .bitmap  = Bitmap.new ( @width, @height ) 
    self .bitmap .fill_rect ( self .bitmap .rect , @@base_color) 
    self .blend_type  = 2  # 混合型(减算) 
    self .z  = 800 
    self .visible  = false 
    @light_cache  = { } 
  end 
 
  # 追加烛光 
  def  add_light( charactor) 
    return  if  charactor.nil ?
    light_type = charactor.light_type 
    return  if  ( light_type < 1  or  light_type > HN_Light::LIGHTS .size ) 
    unless  @light_cache .key ?( light_type) 
      @light_cache [ light_type]  = HN_Light::Light .new ( light_type, @zoom ) 
    end 
    light = @light_cache [ light_type] 
 
    # 画面外什麽都不做 
    if  @zoom  == 1 
      return  if  ( charactor.screen_x  < 0   - light.width  + light.ox ) 
      return  if  ( charactor.screen_x  > @width  + light.ox ) 
      return  if  ( charactor.screen_y  < 0  - light.height  + light.oy ) 
      return  if  ( charactor.screen_y  > @height  + light.oy ) 
    else 
      return  if  ( charactor.screen_x  < 0   - ( light.width  + light.ox )  * @zoom ) 
      return  if  ( charactor.screen_x  > ( @width + light.ox )   * @zoom ) 
      return  if  ( charactor.screen_y  < 0  - ( light.height  + light.oy )  * @zoom ) 
      return  if  ( charactor.screen_y  > ( @height + light.oy )  * @zoom ) 
    end 
 
    # 动画判定 
    if  light.cells  > 1 
      index = ( Graphics.frame_count  / 4 )  % light.cells 
      rect = Rect.new ( index * light.width  , 0 , light.width , light.height ) 
    else 
      rect = light.bitmap .rect 
    end 
    if  @zoom  != 1 
      p_x = charactor.screen_x  / @zoom  - light.ox 
      p_y = ( charactor.screen_y  - 16 )  / @zoom  - light.oy 
    else 
      p_x = charactor.screen_x  - light.ox 
      p_y = charactor.screen_y  - 16  - light.oy 
    end 
 
    # 乗算合成(3) 
    self .bitmap .blend_blt ( p_x, p_y, light.bitmap , rect, 3 ) 
  end 
 
 
  def  refresh
    self .bitmap .fill_rect ( self .bitmap .rect , @@base_color) 
    $game_map .light_events .each  do  |event|
      next  if  HN_Light::LIGHTS [ event.light_type  - 1 ] .nil ?
      add_light( event) 
    end 
    add_light( $game_player) 
  end 
 
  # 更新 
  def  update
    super 
    refresh( ) 
  end 
 
  #-------------------------------------------------------------------------- 
  # ● 解放 
  #-------------------------------------------------------------------------- 
  def  dispose
    self .bitmap .dispose 
    @light_cache .values .each  do  |light|
      light.dispose 
    end 
    super 
  end 
end 
 
 
class  Spriteset_Map  
  # 动画判定 
  def  create_dark
    @dark_sprite  = Sprite_Dark.new ( @viewport1) 
  end 
 
  # 更新黑暗Sprite 
  def  update_dark
    if  ( @dark_sprite.visible  = $game_switches [ HN_Light::DARK_SWITCH ] ) 
      @dark_sprite .update 
    end 
  end 
 
  # 破弃黑暗Sprite 
  def  dispose_dark
    @dark_sprite .dispose 
  end 
 
  # 初期化 
  alias  :_dark__initialize  :initialize  unless  private_method_defined?( :_dark__initialize ) 
  def  initialize
    _dark__initialize( ) 
    create_dark( ) 
    update_dark( ) 
  end 
 
  # 更新 
  alias  :_dark__update  :update  unless  method_defined?( :_dark__update ) 
  def  update
    _dark__update( ) 
    update_dark( )  if  !@dark_sprite.nil ? and  !@dark_sprite.disposed ?
  end 
 
  # 结束处理 
  alias  :_dark__dispose  :dispose  unless  method_defined?( :_dark__dispose ) 
  def  dispose
    dispose_dark( ) 
    _dark__dispose( ) 
  end 
end 
=begin 
  HN_Light version 1.0.1.0 for VX Ace 
        by 半生 
 
  
  要HN_RG_BITMAP(ver 0.1.2.1以降) 
  
2012/01/08 ver 1.0.1.2 
 队列歩行の仲间に対応 
 
2015/04/25 Xp移植 
  By RyanBern 
  
=end 
 
# ----- 在这里设定----- 
module  HN_Light
  # 简略化0:(精细)~2:(粗暴,负荷轻) 
  SIMPLIFY = 1 
 
  # 表示黑暗处的不透明度,数值为0-255,越大则不可见度越高 
  DARK_OPACITY = 190 
 
  # 玩家的烛光类型使用的变量号码 
  PLAYER_LIGHT_TYPE = 13 
 
  # 黑暗判断上使用的开关 
  DARK_SWITCH = 73 
 
  # 烛光事件识别用的正规表达式 
  REGEX_LIGHT = /@LIGHT( \d+) /
 
  # 烛光图像的目录 
  LIGHT_IMG_DIR = "Graphics/Pictures/" 
 
  # 烛光Bitmap设定 
  LIGHTS = [  
  # [文件名  ,格栅数, 放大率,  Y偏移值, 色相] 
    [ "light6" ,     1 ,    5.0 ,        0 ,    0 ] ,
    [ "light6" ,     1 ,    7.5 ,        0 ,    0 ] ,
    [ "light6" ,     1 ,    10.0 ,        0 ,    0 ] ,
    [ "light5" ,     1 ,    12.0 ,      -16 ,    0 ] ,
    [ "light5" ,     1 ,    5.0 ,        0 ,    0 ] ,
    [ "light5" ,     1 ,    15.0 ,        0 ,    0 ] ,
    [ "light7" ,     1 ,    3.0 ,      -16 ,    0 ] ,
    [ "light8" ,     1 ,    0.5 ,        0 ,    0 ] ,
    [ "light9" ,     1 ,    2.0 ,        0 ,    0 ] ,
  ] 
end 
#  ----- 在这里设定 ----- 
 
module  HN_Light
  # 事件mix-in用 
  module  LightEvent
    attr_reader :light_type 
    def  initialize
      super ( ) 
      @light_type  = 0 
    end 
 
    def  check_light
      @light_type  = 0 
      return  if  @list .nil ?
      @list .each  do  |command|
        break  if  @light_type  > 0 
        if  command.code  == 108  or  command.code  == 408 
          command.parameters .each  do  |line|
            if  line =~ REGEX_LIGHT
              @light_type  = $1 .to_i 
              break 
            end 
          end 
        end 
      end  # END @list.each 
    end 
 
  end  # END module LightEvent 
 
 
  class  Light
    attr_reader :bitmap 
    attr_reader :cells 
    attr_reader :width 
    attr_reader :height 
    attr_reader :ox 
    attr_reader :oy 
    def  initialize( light_type, s_zoom = 1 ) 
      light = LIGHTS[ light_type - 1 ] 
      if  light.nil ?
        # 本来不应该来这里 
        @bitmap  = Bitmap.new ( 32 , 32 ) 
        @cels  = 1 
        @zoom  = 1.0 
        @oy  = 16 
        @ox  = 16 
        @width   = 32 
        @height  = 32 
      else 
        @bitmap  = Bitmap.new ( LIGHT_IMG_DIR + light[ 0 ] ) 
        @bitmap .invert ( ) 
        @cells  = light[ 1 ] .to_i 
        @cells  = 1  if  ( @cells < 1  or  @cells  > @bitmap .width ) 
        @zoom  = light[ 2 ] .to_f 
        @zoom  = 1.0  if  @zoom  <= 0.0 
        @zoom  /= s_zoom
        @width   = @bitmap .width  / @cells 
        @height  = @bitmap .height 
 
        # 缩放处理 
        if  @zoom  != 1.0 
          new_width  = ( @width * @zoom ) .round 
          new_height = ( @height * @zoom ) .round 
          if  new_width * new_height < 1 
            @zoom  = 1.0 
          else 
            @width  = new_width
            @height  = new_height
            new_bitmap = Bitmap.new ( @width * @cells , @height ) 
            new_bitmap.stretch_blt ( new_bitmap.rect ,@bitmap, @bitmap .rect ) 
            @bitmap .dispose 
            @bitmap  = new_bitmap
          end 
        end 
        @ox  = @width  / 2 
        @oy  = @height  / 2  - light[ 3 ] .to_i  / s_zoom
 
        # 色相変换 
        if  (  ( hue = light[ 4 ] .to_i )  != 0 ) 
          @bitmap .hue_change ( hue) 
        end 
      end 
    end  # End def initialize 
 
    # 色调转换 
    def  dispose
      @bitmap .dispose 
      @bitmap  = nil 
    end 
  end 
 
end 
 
class  Game_Event
  include  HN_Light::LightEvent 
  alias  :_hn_light__setup  :refresh  unless  method_defined?( :_hn_light__setup ) 
  def  refresh
    _hn_light__setup
    check_light( ) 
  end 
end 
 
class  Game_Player
  def  light_type
    return  $game_variables [ HN_Light::PLAYER_LIGHT_TYPE ] 
  end 
end 
 
class  Game_Map
  attr_reader :light_events 
 
  # 更新烛光事件列表 
  def  refresh_lights
    @light_events  = [ ] 
    @events .values .each  do  |event|
      if  ( event.light_type  > 0 ) 
        @light_events .push ( event) 
      end 
    end 
  end 
 
  alias  :_hn_light__setup_events  :setup  unless  method_defined?( :_hn_light__setup_events ) 
  def  setup( map_id) 
    _hn_light__setup_events( map_id) 
    refresh_lights( ) 
  end 
 
  alias  :_hn_light__refresh  :refresh  unless  method_defined?( :_hn_light__refresh ) 
  def  refresh
    _hn_light__refresh( ) 
    refresh_lights( ) 
  end 
end 
 
class  Sprite_Dark < Sprite
  @@base_color = Color.new ( 255 ,255 ,255 ,HN_Light::DARK_OPACITY ) 
 
  def  initialize( viewport = nil ) 
    super ( viewport) 
    @width  = 640 
    @height  = 480 
 
    case  HN_Light::SIMPLIFY 
    when  1 
      @zoom  = 2 
    when  2 
      @zoom  = 4 
    else 
      @zoom  = 1 
    end 
    @width  /= @zoom 
    @height  /= @zoom 
    self .zoom_x  = @zoom .to_f 
    self .zoom_y  = @zoom .to_f 
 
    self .bitmap  = Bitmap.new ( @width, @height ) 
    self .bitmap .fill_rect ( self .bitmap .rect , @@base_color) 
    self .blend_type  = 2  # 混合型(减算) 
    self .z  = 800 
    self .visible  = false 
    @light_cache  = { } 
  end 
 
  # 追加烛光 
  def  add_light( charactor) 
    return  if  charactor.nil ?
    light_type = charactor.light_type 
    return  if  ( light_type < 1  or  light_type > HN_Light::LIGHTS .size ) 
    unless  @light_cache .key ?( light_type) 
      @light_cache [ light_type]  = HN_Light::Light .new ( light_type, @zoom ) 
    end 
    light = @light_cache [ light_type] 
 
    # 画面外什麽都不做 
    if  @zoom  == 1 
      return  if  ( charactor.screen_x  < 0   - light.width  + light.ox ) 
      return  if  ( charactor.screen_x  > @width  + light.ox ) 
      return  if  ( charactor.screen_y  < 0  - light.height  + light.oy ) 
      return  if  ( charactor.screen_y  > @height  + light.oy ) 
    else 
      return  if  ( charactor.screen_x  < 0   - ( light.width  + light.ox )  * @zoom ) 
      return  if  ( charactor.screen_x  > ( @width + light.ox )   * @zoom ) 
      return  if  ( charactor.screen_y  < 0  - ( light.height  + light.oy )  * @zoom ) 
      return  if  ( charactor.screen_y  > ( @height + light.oy )  * @zoom ) 
    end 
 
    # 动画判定 
    if  light.cells  > 1 
      index = ( Graphics.frame_count  / 4 )  % light.cells 
      rect = Rect.new ( index * light.width  , 0 , light.width , light.height ) 
    else 
      rect = light.bitmap .rect 
    end 
    if  @zoom  != 1 
      p_x = charactor.screen_x  / @zoom  - light.ox 
      p_y = ( charactor.screen_y  - 16 )  / @zoom  - light.oy 
    else 
      p_x = charactor.screen_x  - light.ox 
      p_y = charactor.screen_y  - 16  - light.oy 
    end 
 
    # 乗算合成(3) 
    self .bitmap .blend_blt ( p_x, p_y, light.bitmap , rect, 3 ) 
  end 
 
 
  def  refresh
    self .bitmap .fill_rect ( self .bitmap .rect , @@base_color) 
    $game_map .light_events .each  do  |event|
      next  if  HN_Light::LIGHTS [ event.light_type  - 1 ] .nil ?
      add_light( event) 
    end 
    add_light( $game_player) 
  end 
 
  # 更新 
  def  update
    super 
    refresh( ) 
  end 
 
  #-------------------------------------------------------------------------- 
  # ● 解放 
  #-------------------------------------------------------------------------- 
  def  dispose
    self .bitmap .dispose 
    @light_cache .values .each  do  |light|
      light.dispose 
    end 
    super 
  end 
end 
 
 
class  Spriteset_Map  
  # 动画判定 
  def  create_dark
    @dark_sprite  = Sprite_Dark.new ( @viewport1) 
  end 
 
  # 更新黑暗Sprite 
  def  update_dark
    if  ( @dark_sprite.visible  = $game_switches [ HN_Light::DARK_SWITCH ] ) 
      @dark_sprite .update 
    end 
  end 
 
  # 破弃黑暗Sprite 
  def  dispose_dark
    @dark_sprite .dispose 
  end 
 
  # 初期化 
  alias  :_dark__initialize  :initialize  unless  private_method_defined?( :_dark__initialize ) 
  def  initialize
    _dark__initialize( ) 
    create_dark( ) 
    update_dark( ) 
  end 
 
  # 更新 
  alias  :_dark__update  :update  unless  method_defined?( :_dark__update ) 
  def  update
    _dark__update( ) 
    update_dark( )  if  !@dark_sprite.nil ? and  !@dark_sprite.disposed ?
  end 
 
  # 结束处理 
  alias  :_dark__dispose  :dispose  unless  method_defined?( :_dark__dispose ) 
  def  dispose
    dispose_dark( ) 
    _dark__dispose( ) 
  end 
end 
#使用方法:不透明的物体在光源旁边会产生一个阴影。 
 
#所以,在光源的事件里面(例如火),请在第一页加上一个注释“s”(请不要带引号) 
 
#然后将此脚本命名为“人物阴影”插入到main上方即可。 
 
 
#============================================================================== 
 
# ■ 阴影精灵 (渐变精灵 ) 
 
# 以 Genzai Kawakami的阴影脚本为基础,  
#  Rataime为其重写和更新,  
#  Boushy 为其添加附属功能 
 
#  精灵使者汉化 
 
#============================================================================== 
 
 
CATERPILLAR_COMPATIBLE = true 
 
 
class  Game_Party
 
attr_reader :characters 
 
end 
 
 
class  Sprite_Shadow < RPG::Sprite 
 
 
attr_accessor :character 
 
 
def  initialize( viewport, character = nil ,source = nil ,anglemin=0 ,anglemax=0 ,distancemax=0 ) 
 
   super ( viewport) 
 
   @anglemin =anglemin.to_f 
 
   @anglemax =anglemax.to_f 
 
   @distancemax =distancemax.to_f 
 
   @character  = character
 
   @source  = source
 
   update
 
end 
 
 
def  update
 
   super 
 
 
   if  ( @tile_id != @character .tile_id  or 
 
      @character_name  != @character .character_name  or 
 
      @character_hue  != @character .character_hue ) # and ( @character.screen_x >= 0 and  @character.screen_x <=640 and  @character.screen_y>=0 and  @character.screen_y <= 480) 
 
     @tile_id  = @character .tile_id 
 
     @character_name  = @character .character_name 
 
     @character_hue  = @character .character_hue 
     if    @character_name .include ?( "AC" )  and   not    @character_name .include ?( "=4" ) 
            if  @character .direction  == 4 
      self .mirror  = false 
    else 
       self .mirror  = true 
     end 
     else 
            if  @character .direction  == 4 
      self .mirror  = true 
    else 
       self .mirror  = false 
     end 
     end  
     if  @tile_id  >= 384 
 
       self .bitmap  = RPG::Cache .tile ( $game_map.tileset_name ,
 
         @tile_id , @character .character_hue ) 
 
       self .src_rect .set ( 0 , 0 , 32 , 32 ) 
 
       self .ox  = 16 
 
       self .oy  = 32 
 
     else 
 
       self .bitmap  = RPG::Cache .character ( @character.character_name ,
 
         @character .character_hue ) 
 
       @cw  = bitmap.width  / 4 
 
       @cw  = bitmap.width  / 4  
    if  not    @character_name .include ?( "=4" ) 
       @ch  = bitmap.height  / 4  
     else 
       @ch  = bitmap.height  / 4 
       end 
 
 
       self .ox  = @cw  / 2 
 
       self .oy  = @ch 
 
     end 
 
   end 
 
   self .visible  = ( not  @character .transparent ) 
 
    if  @tile_id  == 0 
      # 设置传送目标的矩形 
    if  not    @character_name .include ?( "=4" ) 
      if  @character .pattern  >= 4 
      sx = ( @character.pattern  - 4 )  * @cw 
        else 
      sx = @character .pattern  * @cw 
    end 
      if  @character .pattern  >= 4 
        sy = ( 4  - 2 )  / 2  * @ch   
       else 
      sy = ( 2  - 2 )  / 2  * @ch  
      end 
      self .src_rect .set ( sx, sy, @cw , @ch ) 
    else 
            sx = @character .pattern  * @cw 
      sy = ( @character.direction  - 2 )  / 2  * @ch 
      self .src_rect .set ( sx, sy, @cw , @ch ) 
      end 
    end 
 
   self .x  = @character .screen_x 
 
   self .y  = @character .screen_y -5 
 
   self .z  = @character .screen_z ( @ch) -1 
 
   self .opacity  = @character .opacity 
 
   self .blend_type  = @character .blend_type 
 
   self .bush_depth  = @character .bush_depth 
 
   #if @character.animation_id != 0 
 
     #animation = $data_animations[@character.animation_id] 
 
    # animation(animation, true) 
 
    # @character.animation_id = 0 
 
   #end 
 
   @deltax =@source.x -self .x 
 
   @deltay = @source .y -self .y 
 
   self .angle  = 57.3 *Math .atan2 ( @deltax, @deltay  ) 
 
   @angle_trigo =self .angle +90 
 
   if  @angle_trigo <0 
 
     @angle_trigo =360 +@angle_trigo
 
   end 
 
   self .color  = Color.new ( 0 , 0 , 0 ) 
 
   @distance  = ( ( @deltax ** 2 )  + ( @deltay ** 2 ) ) 
 
   if $game_map.shadows ==-1 
 
     self .opacity  = 0  
   else 
 
     self .opacity  = 1200000 /( @distance+6000 )     
   end 
 
   if  @character .screen_x  >= 640  or  @character .screen_x  <= 0  or  @character .screen_y  >= 480  or  @character .screen_y  <= 0 
   self .opacity  = 0  
     end    
 
   @distance  = @distance  ** 0.5 
 
   if  @distancemax  !=0  and  @distance >=@distancemax
 
     self .opacity =0 
 
   end 
 
   if  @anglemin  !=0  or  @anglemax  !=0 
 
      if  ( @angle_trigo<@anglemin or  @angle_trigo >@anglemax)  and  @anglemin <@anglemax
 
        self .opacity =0 
 
      end 
 
      if  ( @angle_trigo<@anglemin and  @angle_trigo >@anglemax)  and  @anglemin >@anglemax
 
        self .opacity =0 
 
      end      
 
   end 
 
end 
 
end 
 
 
#=================================================== 
 
# ■ 重定义 Sprite_Character 
 
#=================================================== 
 
 
class  Sprite_Character < RPG::Sprite 
 
alias  shadow_initialize initialize
 
 
def  initialize( viewport, character = nil ) 
 
   @character  = character
  # @character = nil 
   super ( viewport) 
 
   @ombrelist =[ ] 
 
   if  ( character.is_a ?( Game_Event)  and  character.list !=nil  and  character.list [ 0 ] .code  == 108  and  character.list [ 0 ] .parameters  == [ "s" ] ) 
 
     if  ( character.list [ 1 ] !=nil  and  character.list [ 1 ] .code  == 108 ) 
 
       @anglemin =character.list [ 1 ] .parameters [ 0 ] 
 
     end 
 
     if  ( character.list [ 2 ] !=nil  and  character.list [ 2 ] .code  == 108 ) 
 
       @anglemax =character.list [ 2 ] .parameters [ 0 ] 
 
     end 
 
     if  ( character.list [ 3 ] !=nil  and  character.list [ 3 ] .code  == 108 ) 
 
       @distancemax =character.list [ 3 ] .parameters [ 0 ] 
 
     end   
 
    for  i in  $game_map .events .keys .sort 
 
     if  ( $game_map.events [ i] .is_a ?( Game_Event)  and  not  ( $game_map.events [ i] .list [ 0 ] .code  == 108  && ( $game_map.events [ i] .list [ 0 ] .parameters  == [ "NotShadow" ] )  or  $game_map .events [ i] .list [ 0 ] .parameters  == [ "s" ] )  )  #$game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["o"]) 
 
       @ombrelist [ i+1 ]  = Sprite_Shadow.new ( viewport, $game_map .events [ i] ,self ,@anglemin,@anglemax,@distancemax) 
 
     end 
 
    end 
 
    @ombrelist [ 1 ]  = Sprite_Shadow.new ( viewport, $game_player ,self ,@anglemin,@anglemax,@distancemax) 
 
#=================================================== 
 
# ● 原装人物跟随兼容脚本 
 
#=================================================== 
 
if  CATERPILLAR_COMPATIBLE and  $game_party .characters !=nil 
 
 
for  member in  $game_party .characters 
 
   @ombrelist .push ( Sprite_Shadow.new ( viewport, member,self ,@anglemin,@anglemax,@distancemax) ) 
 
end 
 
 
end 
 
#=================================================== 
 
# ● 兼容脚本结束 
 
#=================================================== 
 
   end 
 
   shadow_initialize( viewport, @character ) 
 
end 
 
 
alias  shadow_update update
 
 
def  update
   shadow_update
   if  @ombrelist !=[ ] 
 
     for  i in  [ email] 1 ..@ombrelist.size [ /email] 
  # if @character.x >= 7 # character.x = @x -1 
       if  @ombrelist [ i] !=nil 
 
         @ombrelist [ i] .update 
 
       end 
  # end 
     end 
 
   end 
 
end   
 
 
end 
 
 
#=================================================== 
 
# ■ 新定义类Scene_Save 
 
#=================================================== 
 
class  Scene_Save < Scene_File
 
 
alias  shadows_write_save_data write_save_data
 
 
def  write_save_data( file) 
 
   $game_map .shadows  = nil 
 
   shadows_write_save_data( file) 
 
end 
 
end 
 
 
#=================================================== 
 
# ■ 新定义类 Game_Map 
 
#=================================================== 
 
class  Game_Map
 
attr_accessor :shadows 
 
end 
#使用方法:不透明的物体在光源旁边会产生一个阴影。 
 
#所以,在光源的事件里面(例如火),请在第一页加上一个注释“s”(请不要带引号) 
 
#然后将此脚本命名为“人物阴影”插入到main上方即可。 
 
 
#============================================================================== 
 
# ■ 阴影精灵 (渐变精灵 ) 
 
# 以 Genzai Kawakami的阴影脚本为基础,  
#  Rataime为其重写和更新,  
#  Boushy 为其添加附属功能 
 
#  精灵使者汉化 
 
#============================================================================== 
 
 
CATERPILLAR_COMPATIBLE = true 
 
 
class  Game_Party
 
attr_reader :characters 
 
end 
 
 
class  Sprite_Shadow < RPG::Sprite 
 
 
attr_accessor :character 
 
 
def  initialize( viewport, character = nil ,source = nil ,anglemin=0 ,anglemax=0 ,distancemax=0 ) 
 
   super ( viewport) 
 
   @anglemin =anglemin.to_f 
 
   @anglemax =anglemax.to_f 
 
   @distancemax =distancemax.to_f 
 
   @character  = character
 
   @source  = source
 
   update
 
end 
 
 
def  update
 
   super 
 
 
   if  ( @tile_id != @character .tile_id  or 
 
      @character_name  != @character .character_name  or 
 
      @character_hue  != @character .character_hue ) # and ( @character.screen_x >= 0 and  @character.screen_x <=640 and  @character.screen_y>=0 and  @character.screen_y <= 480) 
 
     @tile_id  = @character .tile_id 
 
     @character_name  = @character .character_name 
 
     @character_hue  = @character .character_hue 
     if    @character_name .include ?( "AC" )  and   not    @character_name .include ?( "=4" ) 
            if  @character .direction  == 4 
      self .mirror  = false 
    else 
       self .mirror  = true 
     end 
     else 
            if  @character .direction  == 4 
      self .mirror  = true 
    else 
       self .mirror  = false 
     end 
     end  
     if  @tile_id  >= 384 
 
       self .bitmap  = RPG::Cache .tile ( $game_map.tileset_name ,
 
         @tile_id , @character .character_hue ) 
 
       self .src_rect .set ( 0 , 0 , 32 , 32 ) 
 
       self .ox  = 16 
 
       self .oy  = 32 
 
     else 
 
       self .bitmap  = RPG::Cache .character ( @character.character_name ,
 
         @character .character_hue ) 
 
       @cw  = bitmap.width  / 4 
 
       @cw  = bitmap.width  / 4  
    if  not    @character_name .include ?( "=4" ) 
       @ch  = bitmap.height  / 4  
     else 
       @ch  = bitmap.height  / 4 
       end 
 
 
       self .ox  = @cw  / 2 
 
       self .oy  = @ch 
 
     end 
 
   end 
 
   self .visible  = ( not  @character .transparent ) 
 
    if  @tile_id  == 0 
      # 设置传送目标的矩形 
    if  not    @character_name .include ?( "=4" ) 
      if  @character .pattern  >= 4 
      sx = ( @character.pattern  - 4 )  * @cw 
        else 
      sx = @character .pattern  * @cw 
    end 
      if  @character .pattern  >= 4 
        sy = ( 4  - 2 )  / 2  * @ch   
       else 
      sy = ( 2  - 2 )  / 2  * @ch  
      end 
      self .src_rect .set ( sx, sy, @cw , @ch ) 
    else 
            sx = @character .pattern  * @cw 
      sy = ( @character.direction  - 2 )  / 2  * @ch 
      self .src_rect .set ( sx, sy, @cw , @ch ) 
      end 
    end 
 
   self .x  = @character .screen_x 
 
   self .y  = @character .screen_y -5 
 
   self .z  = @character .screen_z ( @ch) -1 
 
   self .opacity  = @character .opacity 
 
   self .blend_type  = @character .blend_type 
 
   self .bush_depth  = @character .bush_depth 
 
   #if @character.animation_id != 0 
 
     #animation = $data_animations[@character.animation_id] 
 
    # animation(animation, true) 
 
    # @character.animation_id = 0 
 
   #end 
 
   @deltax =@source.x -self .x 
 
   @deltay = @source .y -self .y 
 
   self .angle  = 57.3 *Math .atan2 ( @deltax, @deltay  ) 
 
   @angle_trigo =self .angle +90 
 
   if  @angle_trigo <0 
 
     @angle_trigo =360 +@angle_trigo
 
   end 
 
   self .color  = Color.new ( 0 , 0 , 0 ) 
 
   @distance  = ( ( @deltax ** 2 )  + ( @deltay ** 2 ) ) 
 
   if $game_map.shadows ==-1 
 
     self .opacity  = 0  
   else 
 
     self .opacity  = 1200000 /( @distance+6000 )     
   end 
 
   if  @character .screen_x  >= 640  or  @character .screen_x  <= 0  or  @character .screen_y  >= 480  or  @character .screen_y  <= 0 
   self .opacity  = 0  
     end    
 
   @distance  = @distance  ** 0.5 
 
   if  @distancemax  !=0  and  @distance >=@distancemax
 
     self .opacity =0 
 
   end 
 
   if  @anglemin  !=0  or  @anglemax  !=0 
 
      if  ( @angle_trigo<@anglemin or  @angle_trigo >@anglemax)  and  @anglemin <@anglemax
 
        self .opacity =0 
 
      end 
 
      if  ( @angle_trigo<@anglemin and  @angle_trigo >@anglemax)  and  @anglemin >@anglemax
 
        self .opacity =0 
 
      end      
 
   end 
 
end 
 
end 
 
 
#=================================================== 
 
# ■ 重定义 Sprite_Character 
 
#=================================================== 
 
 
class  Sprite_Character < RPG::Sprite 
 
alias  shadow_initialize initialize
 
 
def  initialize( viewport, character = nil ) 
 
   @character  = character
  # @character = nil 
   super ( viewport) 
 
   @ombrelist =[ ] 
 
   if  ( character.is_a ?( Game_Event)  and  character.list !=nil  and  character.list [ 0 ] .code  == 108  and  character.list [ 0 ] .parameters  == [ "s" ] ) 
 
     if  ( character.list [ 1 ] !=nil  and  character.list [ 1 ] .code  == 108 ) 
 
       @anglemin =character.list [ 1 ] .parameters [ 0 ] 
 
     end 
 
     if  ( character.list [ 2 ] !=nil  and  character.list [ 2 ] .code  == 108 ) 
 
       @anglemax =character.list [ 2 ] .parameters [ 0 ] 
 
     end 
 
     if  ( character.list [ 3 ] !=nil  and  character.list [ 3 ] .code  == 108 ) 
 
       @distancemax =character.list [ 3 ] .parameters [ 0 ] 
 
     end   
 
    for  i in  $game_map .events .keys .sort 
 
     if  ( $game_map.events [ i] .is_a ?( Game_Event)  and  not  ( $game_map.events [ i] .list [ 0 ] .code  == 108  && ( $game_map.events [ i] .list [ 0 ] .parameters  == [ "NotShadow" ] )  or  $game_map .events [ i] .list [ 0 ] .parameters  == [ "s" ] )  )  #$game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["o"]) 
 
       @ombrelist [ i+1 ]  = Sprite_Shadow.new ( viewport, $game_map .events [ i] ,self ,@anglemin,@anglemax,@distancemax) 
 
     end 
 
    end 
 
    @ombrelist [ 1 ]  = Sprite_Shadow.new ( viewport, $game_player ,self ,@anglemin,@anglemax,@distancemax) 
 
#=================================================== 
 
# ● 原装人物跟随兼容脚本 
 
#=================================================== 
 
if  CATERPILLAR_COMPATIBLE and  $game_party .characters !=nil 
 
 
for  member in  $game_party .characters 
 
   @ombrelist .push ( Sprite_Shadow.new ( viewport, member,self ,@anglemin,@anglemax,@distancemax) ) 
 
end 
 
 
end 
 
#=================================================== 
 
# ● 兼容脚本结束 
 
#=================================================== 
 
   end 
 
   shadow_initialize( viewport, @character ) 
 
end 
 
 
alias  shadow_update update
 
 
def  update
   shadow_update
   if  @ombrelist !=[ ] 
 
     for  i in  [ email] 1 ..@ombrelist.size [ /email] 
  # if @character.x >= 7 # character.x = @x -1 
       if  @ombrelist [ i] !=nil 
 
         @ombrelist [ i] .update 
 
       end 
  # end 
     end 
 
   end 
 
end   
 
 
end 
 
 
#=================================================== 
 
# ■ 新定义类Scene_Save 
 
#=================================================== 
 
class  Scene_Save < Scene_File
 
 
alias  shadows_write_save_data write_save_data
 
 
def  write_save_data( file) 
 
   $game_map .shadows  = nil 
 
   shadows_write_save_data( file) 
 
end 
 
end 
 
 
#=================================================== 
 
# ■ 新定义类 Game_Map 
 
#=================================================== 
 
class  Game_Map
 
attr_accessor :shadows 
 
end