#==============================================================================
# ☆ 人物影子 ☆ (芯☆淡茹水)
#==============================================================================
# ★ 使用方法:复制该脚本,插入到 main 前。
#==============================================================================
# ★ 冲突:尚未发现。
#==============================================================================
# ★ ↓设置↓
#----------------------------------------------------------------------------
module X☆R
#--------------------------------------------------------------------------
#不需要显示人物影子的地图ID。(比如室内,山洞)
Not_Shadow_Id = [0]
#--------------------------------------------------------------------------
#不需要显示人物影子的行走图名。(比如 行走图已有影子, 门, 鬼魂?,,,)
Not_Shadow_Name = ["","170-Door01"]
#--------------------------------------------------------------------------
#控制影子显示的开关ID,打开-显示;关闭-不显示。(比如突然阴天下雨)
Control_Sv_Id = 489
#--------------------------------------------------------------------------
#影子的透明度。
Shadow_Opacity = 80
#--------------------------------------------------------------------------
#影子X轴方向的放大率调整。
Shadow_Zoom_X = 0.7
#--------------------------------------------------------------------------
#光照方向的变量ID,变量值为光照角度, 范围: 0..360。(12点0度,逆时针)
Shadow_Angle_Var = 10
#--------------------------------------------------------------------------
#光照高度的变量ID,变量值为光照高度, 范围: 0..90。
Beam_Height_Var = 11
#--------------------------------------------------------------------------
#飞行类行走图名。该类的影子需要距离本体较远。
Flay_Name = ["159-Small01","163-Small05","164-Small06","165-Small07"]
#--------------------------------------------------------------------------
#飞行类影子为正常影子缩小的百分比。(飞行类影子偏小)
Flay_Narrow_Rate = 80
#--------------------------------------------------------------------------
#飞行类影子距离本体左右偏移最大像素值
Flay_Add_X = 32
#--------------------------------------------------------------------------
#飞行类影子距离本体往下的像素值。
Flay_Add_Y = 64
end
#==============================================================================
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
alias x☆r_initialize_sd initialize
def initialize(viewport, character = nil)
initialize_shadow(viewport)
x☆r_initialize_sd(viewport, character)
end
#--------------------------------------------------------------------------
alias x☆r_update_sd update
def update; update_shadow; x☆r_update_sd; end
#--------------------------------------------------------------------------
def dispose
@shadow.bitmap.dispose if @shadow.bitmap
@shadow.dispose
super
end
#--------------------------------------------------------------------------
def initialize_shadow(viewport)
[url=home.php?mod=space&uid=31758]@Shadow[/url] = Sprite.new(viewport)
@shadow.color = Color.new(0,0,0)
set_data
end
#--------------------------------------------------------------------------
def update_shadow
if @data_show != $game_switches[X☆R::Control_Sv_Id]
@data_show = $game_switches[X☆R::Control_Sv_Id]
@shadow.visible = @data_show ? have_shadow? : false
end
return unless @data_show
set_data if need_refresh
make_shadow if @character_name != @character.character_name
@shadow.update if @shadow.bitmap
set_shadow if @shadow.bitmap
end
#--------------------------------------------------------------------------
def need_refresh
return true if @data_var_a != $game_variables[X☆R::Shadow_Angle_Var]
return true if @data_var_b != $game_variables[X☆R::Beam_Height_Var]
return false
end
#--------------------------------------------------------------------------
def set_data
@data_var_a = $game_variables[X☆R::Shadow_Angle_Var]
@data_var_b = $game_variables[X☆R::Beam_Height_Var]
@shadow.angle = (@data_var_a.abs + 180) % 360
zoom_x = X☆R::Shadow_Zoom_X
zoom_x = zoom_x * X☆R::Flay_Narrow_Rate / 100 if @flay
@shadow.zoom_x = zoom_x
@shadow.zoom_y = angle_count
@shadow_direction = case @shadow.angle
when 0..44 :[0,1,2,3]
when 45..134 :[1,3,0,2]
when 135..224 :[3,2,1,0]
when 225..314 :[2,0,3,1]
when 315..359 :[0,1,2,3]
end
end
#--------------------------------------------------------------------------
def angle_count
ag = @data_var_b % 91; max = 4.0;
ag.times{max -= max / 40}
n = [max, 0.4].max; n = n * X☆R::Flay_Narrow_Rate / 100 if @flay
return n
end
#--------------------------------------------------------------------------
def add_place_count
@add_y = @flay ? X☆R::Flay_Add_Y : -2
@add_y -= 10 if (135..224).include?(@shadow.angle)
@add_x = @shadow.angle >= 180 ? -2 : 2
return unless @flay
ag = @shadow.angle >= 180 ? (@shadow.angle - 180) : @shadow.angle
n = ag % 90; n = ag > 90 ? 90-n : n
n = n * X☆R::Flay_Add_X / 90.0
@add_x = @shadow.angle > 180 ? n : -n
end
#--------------------------------------------------------------------------
def have_shadow?
return false if @character.tile_id >= 384
return false if @character.character_name == ""
return false if X☆R::Not_Shadow_Id.include?($game_map.map_id)
return false if X☆R::Not_Shadow_Name.include?(@character.character_name)
return true
end
#--------------------------------------------------------------------------
def make_shadow
@shadow.bitmap.dispose if @shadow.bitmap
s_bitmap = RPG::Cache.character(@character.character_name,0)
@shadow.bitmap = have_shadow? ? s_bitmap : nil
return unless @shadow.bitmap
@aw = s_bitmap.width / 4; @ah = s_bitmap.height / 4
@shadow.ox = @aw / 2; @shadow.oy = @ah
@flay = (X☆R::Flay_Name.include?(@character.character_name))
set_data
add_place_count
end
#--------------------------------------------------------------------------
def set_shadow
@shadow.visible = (! @character.transparent)
return unless @shadow.visible
ax = @character.pattern * @aw
ay = @shadow_direction[(@character.direction - 2) / 2] * @ah
@shadow.src_rect.set(ax, ay, @aw, @ah)
@shadow.x = @character.screen_x + @add_x
@shadow.y = @character.screen_y + @add_y
@shadow.z = @character.screen_z + (@flay ? 9999 : 0)
@shadow.opacity = @character.opacity * X☆R::Shadow_Opacity / 255
@shadow.blend_type = @character.blend_type
end
end
#==============================================================================