#==============================================================================
# ■ 角色装备行走图变更 BY:亿万星辰
#------------------------------------------------------------------------------
# 使用了一种特殊的方法来改变行走图,不是更换,而是在原图的基础上继续描绘新的
# 层以实现层的叠加,类似暗黑里的装备帽子以后角色的行走图就多出帽子,装备盾牌以
# 后就会看到角色的左手拿着盾牌。
#
# 介绍:
# 现在默认分为5层,最下为默认的行走图,也就是数据库里角色那里设置的。之后分为头
# 部、身体、左右手4层,也可自行添加,但需要一定的功底,以防备逻辑上的混乱……
#
# 使用说明:
# 全部都是在数据库里设置,对应的武器或防具后逗号追加一个图片文件名即可,此文件
# 放在graphics/characters下,至于图片的绘制,实属虐待美工…… 具体可参考范例里
# 的graphics/characters目录,不过盾牌的图画的不是很合适
#==============================================================================
module RPG
class Weapon
def name
return @name.split(/,/)[0].nil? ? "" : @name.split(/,/)[0]
end
def part
return @name.split(/,/)[1].nil? ? "" : @name.split(/,/)[1]
end
end
class Armor
def name
return @name.split(/,/)[0].nil? ? "" : @name.split(/,/)[0]
end
def part
return @name.split(/,/)[1].nil? ? "" : @name.split(/,/)[1]
end
end
end
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
# 处理主角的类。事件启动的判定、以及地图的滚动等功能。
# 本类的实例请参考 $game_player。
#==============================================================================
class Game_Player < Game_Character
attr_accessor :part_name # 角色 文件名
attr_accessor :turn_z
=begin
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super
@turn_z = [0,3,4,1,2] # 优先级,靠后的显示在最前 0主身体 1武器 2盾牌 3身体 4头
@part_name = [
$game_party.actors[0].character_name,
$game_party.actors[0].weapon_id != 0 ? $data_weapons[$game_party.actors[0].weapon_id].part : "",
$game_party.actors[0].armor1_id != 0 ? $data_armors[$game_party.actors[0].armor1_id].part : "",
$game_party.actors[0].armor2_id != 0 ? $data_armors[$game_party.actors[0].armor2_id].part : "",
$game_party.actors[0].armor3_id != 0 ? $data_armors[$game_party.actors[0].armor3_id].part : ""]
end
=end
#--------------------------------------------------------------------------
def refresh
# 同伴人数为 0 的情况下
if $game_party.actors.size == 0
# 清除角色的文件名及对像
@character_name = ""
@character_hue = 0
#修改-------------------------------------------------------------------------
@turn_z = [0,3,4,1,2,5]
@part_name = ["","","","","",""]
# 分支结束
return
end
# 获取带头的角色
actor = $game_party.actors[0]
#-----------------------------------
# X☆R: 貌似放在这儿比较好一点。
@turn_z = case @direction
#修改-------------------------------------------------------------------------
# 优先级,靠后的显示在最前 0主身体 1武器.发1 2盾牌.发2 3身体.衣服 4头.裤子 5鞋子
when 2 :[0,3,4,1,2,5] #面向向下
when 4 :[1,0,3,4,2,5] #面向向左
when 6 :[2,0,3,4,1,5] #面向向右
when 8 :[0,1,2,3,4,5] #面向向上
end
@part_name = [actor.character_name,
actor.weapon_id != 0 ? $data_weapons[actor.weapon_id].part : "",
actor.armor1_id != 0 ? $data_armors[actor.armor1_id].part : "",
actor.armor2_id != 0 ? $data_armors[actor.armor2_id].part : "",
actor.armor3_id != 0 ? $data_armors[actor.armor3_id].part : "",
actor.armor4_id != 0 ? $data_armors[actor.armor4_id].part : ""]
#------------------------------------
# 设置角色的文件名及对像
@character_name = actor.character_name
@character_hue = actor.character_hue
# 初始化不透明度和合成方式
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# ● 面向向下
#--------------------------------------------------------------------------
def turn_down
unless @direction_fix
@direction = 2
@stop_count = 0
@turn_z = [0,3,4,1,2,5] # 优先级,靠后的显示在最前
end
end
#--------------------------------------------------------------------------
# ● 面向向左
#--------------------------------------------------------------------------
def turn_left
unless @direction_fix
@direction = 4
@stop_count = 0
@turn_z = [1,0,3,4,2,5] # 优先级,靠后的显示在最前
end
end
#--------------------------------------------------------------------------
# ● 面向向右
#--------------------------------------------------------------------------
def turn_right
unless @direction_fix
@direction = 6
@stop_count = 0
@turn_z = [2,0,3,4,1,5] # 优先级,靠后的显示在最前
end
end
#--------------------------------------------------------------------------
# ● 面向向上
# (这里感觉不太好处理,有些时候有的图一步在角色主图前,一步在角色主图后,
# 不怎么好处理,只能麻烦美工了……比如范例里的盾牌……)
#--------------------------------------------------------------------------
def turn_up
unless @direction_fix
@direction = 8
@stop_count = 0
@turn_z = [0,1,2,3,4,5] # 优先级,靠后的显示在最前
end
end
end
#==============================================================================
# ■ Sprite_Character
#------------------------------------------------------------------------------
# 角色显示用脚本。监视 Game_Character 类的实例、
# 自动变化脚本状态。
#==============================================================================
class Sprite_Player < RPG::Sprite
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :part # 角色
#--------------------------------------------------------------------------
# ● 初始化对像
# viewport : 查看端口
# character : 角色 (Game_Character)
#--------------------------------------------------------------------------
def initialize(viewport, part)
super(viewport)
@part = part
[url=home.php?mod=space&uid=2631396]@character[/url] = $game_player
self.z += $game_player.turn_z.index(part)
update
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
# 元件 ID、文件名、色相与现在的情况存在差异的情况下
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# 记忆元件 ID 与文件名、色相
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# 元件 ID 为有效值的情况下
pic = @character.part_name[@part]
self.bitmap = RPG::Cache.character(pic, @character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
# 设置可视状态
self.visible = (not @character.transparent)
# 图形是角色的情况下
if @tile_id == 0
# 设置传送目标的矩形
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# 设置脚本的坐标
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.turn_z.index(part)
# 设置不透明度、合成方式、茂密
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
end
end
class Spriteset_Map
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 1280, 704)
@viewport2 = Viewport.new(0, 0, 1280, 704)
@viewport3 = Viewport.new(0, 0, 1280, 704)
@viewport2.z = 200
@viewport3.z = 5000
# 生成元件地图
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
# 生成远景平面
[url=home.php?mod=space&uid=2658185]@Panorama[/url] = Plane.new(@viewport1)
@panorama.z = -1000
# 生成雾平面
[url=home.php?mod=space&uid=14217]@fog[/url] = Plane.new(@viewport1)
@fog.z = 3000
# 生成角色活动块
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Player.new(@viewport1, 0)) # 主体
@character_sprites.push(Sprite_Player.new(@viewport1, 1)) # 武器
@character_sprites.push(Sprite_Player.new(@viewport1, 2)) # 盾牌
@character_sprites.push(Sprite_Player.new(@viewport1, 3)) # 身体
@character_sprites.push(Sprite_Player.new(@viewport1, 4)) # 头
@character_sprites.push(Sprite_Player.new(@viewport1, 5)) #饰品
# 生成天气
@weather = RPG::Weather.new(@viewport1)
# 生成图片
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures[i]))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
# 刷新画面
update
end
end
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# X☆R
def self_is_player?
return $game_party.actors[0] == self
end
#--------------------------------------------------------------------------
# ● 变更装备
# equip_type : 装备类型
# id : 武器 or 防具 ID (0 为解除装备)
#--------------------------------------------------------------------------
alias add_equip_xdrs equip
def equip(equip_type, id)
add_equip_xdrs(equip_type, id)
$game_player.refresh if self_is_player? #X☆R
end
end
#==============================================================================