赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 3030 |
最后登录 | 2012-7-8 |
在线时间 | 98 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 98 小时
- 注册时间
- 2011-1-9
- 帖子
- 37
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
npc脚本
#==============================================================================
# 显示NPC名
#------------------------------------------------------------------------------
# 跟原版一样,EV开头的不显示,逗号后加颜色代码
# 修改某事件名的方法:
# set_npc_name("新名", 事件ID, 地图ID, 是否永久生效)
# 事件ID 为空时表示当前事件
# 地图ID 为空时表示当前地图
# 是否永久生效 默认永久,否则只允许修改当前地图
#==============================================================================
# 参数设定
#==============================================================================
module NPC
NAME_FONT = "黑体"
NAME_SIZE = 16
NAME_SHADOW = false
NAME_WIDTH = 120
end
#==============================================================================
# 重定事件名
#==============================================================================
def set_npc_name(name, event_id = nil, map_id = nil, forever = true)
# 处理事件 ID
if event_id == nil
event_id = $game_map.interpreter.event_id
end
# 处理地图 ID
if map_id == nil
$game_map.events[event_id].name = name
map_id = $game_map.map_id
else
map_id = map_id
end
return unless forever
data = load_data(sprintf("Data/Map%03d.rvdata", map_id))
# 更改名
data.events[event_id].name = name
save_data(data, sprintf("Data/Map%03d.rvdata", map_id))
end
#==============================================================================
# ■ Game_Character
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# ◎ 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :name # 名称
#--------------------------------------------------------------------------
# ◎ 初始化对象
#--------------------------------------------------------------------------
alias character_ini initialize
def initialize
character_ini
@name = ""
end
end
#==============================================================================
# ■ Game_Event
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# ◎ 定义实例变量
#--------------------------------------------------------------------------
attr_reader :erased
#--------------------------------------------------------------------------
# ◎ 初始化对像
# map_id : 地图 ID
# event : 事件 (RPG::Event)
#--------------------------------------------------------------------------
alias event_ini initialize
def initialize(map_id, event)
event_ini(map_id, event)
@name = @event.name
end
end
#==============================================================================
# ■ Game_Player
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ◎ 获取角色名
#--------------------------------------------------------------------------
def name
return $game_party.members[0].name
end
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ◎ 定义实例变量
#--------------------------------------------------------------------------
attr_reader :event_id
end
#==============================================================================
# ■ Sprite_Character
#==============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# ◎ 初始化对象
# viewport : 视区
# character : 角色 (Game_Character)
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
super(viewport)
@character = character
@balloon_duration = 0
## 名称
@name = @character.name
set_name_sprite
update
end
#--------------------------------------------------------------------------
# ◎ 释放
#--------------------------------------------------------------------------
def dispose
dispose_balloon
super
##
return if @name_sprite == nil
@name_sprite.bitmap.dispose
@name_sprite.dispose
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_bitmap
self.visible = (not @character.transparent)
update_src_rect
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
update_balloon
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
start_animation(animation)
@character.animation_id = 0
end
if @character.balloon_id != 0
@balloon_id = @character.balloon_id
start_balloon
@character.balloon_id = 0
end
## 名称可视和跟随
unless @name_sprite == nil or @name_sprite.disposed?
if @character.is_a?(Game_Event) and @character.erased
@name_sprite.visible = false
return
else
@name_sprite.visible = true
end
if @character.is_a?(Game_Player) and @character.in_vehicle?
@name_sprite.visible = false
return
else
@name_sprite.visible = true
end
if @name != @character.name
@name = @character.name
refresh_name_sprite
end
@name_sprite.x = self.x - 80
@name_sprite.y = self.y - self.height - NPC::NAME_SIZE+2
@name_sprite.z = self.z+1
end
end
#--------------------------------------------------------------------------
# ○ 设定 NPC 名称
#--------------------------------------------------------------------------
def set_name_sprite
return if @character.name[0, 2] == "EV"
return if @character.name == ""
return if @character.character_name == ""
return if @character.is_a?(Game_Event) and @character.erased
@color_board = Window_Base.new(0,0,33,33)
@color_board.visible = false
@name_sprite = Sprite.new
@name_sprite.bitmap = Bitmap.new(NPC::NAME_WIDTH, NPC::NAME_SIZE+2)
@name_sprite.bitmap.font.name = NPC::NAME_FONT
@name_sprite.bitmap.font.size = NPC::NAME_SIZE
@name_sprite.bitmap.font.shadow = NPC::NAME_SHADOW
refresh_name_sprite
end
#--------------------------------------------------------------------------
# ○ 更新 NPC 名称
#--------------------------------------------------------------------------
def refresh_name_sprite
name,color_index = @name.split(/,/)
color_index = 0 if color_index == ""
@name_sprite.bitmap.font.color = @color_board.text_color(color_index.to_i)
@name_sprite.bitmap.clear
@name_sprite.bitmap.draw_text(0,0,160,NPC::NAME_SIZE+2,name,1)
end
end
地名脚本
#▼▼▼区域,地图,地区名显示▼▼▼ by trentswd
#==============================================================================
# ■ Map_Window
#------------------------------------------------------------------------------
# 游戏中显示地名的窗口。
#=============================================================================
class Map_Window<Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(-(5+T_m::WIDTH),T_m::MWINDOW_Y,T_m::WIDTH,T_m::HEIGHT)
self.windowskin = Cache.system(T_m::SKIN)
create_contents
self.opacity = 255
self.contents_opacity = 255
self.contents.font.name=["华文细黑","STXihei","黑体"]
@id=$game_map.map_id
@time=0
@a_id=$game_player.area_id
@zone_change=false
@a_name=""
@a_name=area_name if @a_id.is_a?(Numeric)
@preview_not_dis=true
end
#--------------------------------------------------------------------------
# ● 地区标记为改变
#--------------------------------------------------------------------------
def zone_change
@zone_change=true
end
#--------------------------------------------------------------------------
# ● 得到地名
#--------------------------------------------------------------------------
def name(id=$game_map.map_id)
name=$game_map.name[id].name.split(/@/)[0]
return name
end
#--------------------------------------------------------------------------
# ● 得到区域名
#--------------------------------------------------------------------------
def area_name(id=$game_player.area_id)
name=$data_areas[id].name.split(/@/)[0]
return name
end
#--------------------------------------------------------------------------
# ● 得到地区名
#--------------------------------------------------------------------------
def zone(id=$game_map.map_id)
name=$game_map.name[id].name.split(/@/)[1]
return name
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if @a_id!=$game_player.area_id
@a_id=$game_player.area_id
if @a_id.is_a?(Numeric) && $game_switches[T_m::Map_W_S] == true && (area_name.split(/,/)[0]!="2"&&area_name.split(/,/)[0]!="6"&&area_name.split(/,/)[0]!="4"&&area_name.split(/,/)[0]!="8")&&self.area_name!=@a_name
@a_name=self.area_name
@preview_not_dis=false
T_m::preview_dis=false
self.width=[T_m::WIDTH,T_m::TEXT1_SIZE*self.name.size/3+50].max
if @time==0
self.x=-5-self.width
end
create_contents
self.contents.font.size=T_m::TEXT1_SIZE
self.contents.font.color=T_m::TEXT1_COLOR
self.contents.draw_text(0,0,self.width-32,T_m::TEXT1_SIZE,self.area_name)
self.contents.font.size=T_m::TEXT2_SIZE
self.contents.font.color=T_m::TEXT2_COLOR
self.contents.draw_text(0,T_m::TEXT1_SIZE+2,self.width-32,T_m::TEXT2_SIZE,$game_actors[T_m::ZONE_NUM].name)
#~ if @time==0
@time=T_m::IN_TIME+T_m::SHOW_TIME+T_m::FADE_TIME
#~ elsif @time>T_m::SHOW_TIME+T_m::FADE_TIME
#~ @time=@time
#~ elsif @time>T_m::FADE_TIME
#~ @time=T_m::SHOW_TIME+T_m::FADE_TIME
#~ else
#~ @time=T_m::IN_TIME+(-self.width-5-self.x)/(self.width/T_m::IN_TIME)+T_m::SHOW_TIME+T_m::FADE_TIME
#~ end
elsif $game_switches[T_m::Map_W_S] == true && $game_player.area_id.is_a?(Numeric)==false
@a_name=self.name
if T_m::preview_dis
T_m::preview_dis=false
else
self.width=[T_m::WIDTH,T_m::TEXT1_SIZE*self.name.size/3+50].max
if @time==0
self.x=-5-self.width
end
create_contents
self.contents.font.size=T_m::TEXT1_SIZE
self.contents.font.color=T_m::TEXT1_COLOR
self.contents.draw_text(0,0,self.width-32,T_m::TEXT1_SIZE,self.name)
self.contents.font.size=T_m::TEXT2_SIZE
self.contents.font.color=T_m::TEXT2_COLOR
self.contents.draw_text(0,T_m::TEXT1_SIZE+2,self.width-32,T_m::TEXT2_SIZE,$game_actors[T_m::ZONE_NUM].name)
#~ if @time==0
@time=T_m::IN_TIME+T_m::SHOW_TIME+T_m::FADE_TIME
#~ elsif @time>T_m::SHOW_TIME+T_m::FADE_TIME
#~ @time=@time
#~ elsif @time>T_m::FADE_TIME
#~ @time=T_m::SHOW_TIME+T_m::FADE_TIME
#~ else
#~ @time=T_m::IN_TIME+(-self.width-5-self.x)/(self.width/T_m::IN_TIME)+T_m::SHOW_TIME+T_m::FADE_TIME
#~ end
end
end
end
if @id!=$game_map.map_id
self.contents.clear
@id=$game_map.map_id
if $game_switches[T_m::Map_W_S] == true
if @zone_change == true
if self.zone==nil || self.zone==""
else
$game_actors[T_m::ZONE_NUM].name=self.zone
end
end
self.width=[T_m::WIDTH,T_m::TEXT1_SIZE*self.name.size/3+50].max
if @time==0
self.x=-5-self.width
end
create_contents
self.contents.font.size=T_m::TEXT1_SIZE
self.contents.font.color=T_m::TEXT1_COLOR
if $game_player.area_id.is_a?(Numeric)
mapname=self.area_name if (self.area_name!= nil && self.area_name!= "")
else
mapname=self.name
end
self.contents.draw_text(0,0,self.width-32,T_m::TEXT1_SIZE,mapname)
self.contents.font.size=T_m::TEXT2_SIZE
self.contents.font.color=T_m::TEXT2_COLOR
self.contents.draw_text(0,T_m::TEXT1_SIZE+2,self.width-32,T_m::TEXT2_SIZE,$game_actors[T_m::ZONE_NUM].name)
#~ if @time==0
@time=T_m::IN_TIME+T_m::SHOW_TIME+T_m::FADE_TIME
#~ elsif @time>T_m::SHOW_TIME+T_m::FADE_TIME
#~ @time=@time
#~ elsif @time>T_m::FADE_TIME
#~ @time=T_m::SHOW_TIME+T_m::FADE_TIME
#~ else
#~ @time=T_m::IN_TIME+(-self.width-5-self.x)/(self.width/T_m::IN_TIME)+T_m::SHOW_TIME+T_m::FADE_TIME
#~ end
end
end
if @direct==1
self.contents.clear
self.width=[T_m::WIDTH,T_m::TEXT1_SIZE*self.name.size/3+50].max
if @time==0
self.x=-5-self.width
end
create_contents
self.contents.font.size=T_m::TEXT1_SIZE
self.contents.font.color=T_m::TEXT1_COLOR
dname=@a_name
self.contents.draw_text(0,0,self.width-32,T_m::TEXT1_SIZE,dname)
self.contents.font.size=T_m::TEXT2_SIZE
self.contents.font.color=T_m::TEXT2_COLOR
self.contents.draw_text(0,T_m::TEXT1_SIZE+2,self.width-32,T_m::TEXT2_SIZE,$game_actors[T_m::ZONE_NUM].name)
@time=T_m::IN_TIME+T_m::SHOW_TIME+T_m::FADE_TIME
@direct=0
end
if @time>T_m::SHOW_TIME+T_m::FADE_TIME
self.opacity = 255*(T_m::IN_TIME+T_m::SHOW_TIME+T_m::FADE_TIME-@time)/(T_m::IN_TIME-1)
self.contents_opacity = 255*(T_m::IN_TIME+T_m::SHOW_TIME+T_m::FADE_TIME-@time)/(T_m::IN_TIME-1)
self.x = -self.width-5+self.width*(T_m::IN_TIME+T_m::SHOW_TIME+T_m::FADE_TIME-@time)/(T_m::IN_TIME-1)
@time-=1
elsif @time>T_m::FADE_TIME
@time-=1
elsif @time>0
self.opacity = 255*(@time-1)/(T_m::FADE_TIME-1)
self.contents_opacity = 255*(@time-1)/(T_m::FADE_TIME-1)
self.x = -self.width-5+self.width*(@time-1)/(T_m::FADE_TIME-1)
@time-=1
else
self.opacity = 0
self.contents_opacity = 0
self.x = -self.width-5
end
end
#--------------------------------------------------------------------------
# ● 直接显示
#--------------------------------------------------------------------------
def d_display
@direct=1
end
end
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
# 对Scene_Map的追加定义。
#==============================================================================
class Scene_Map < Scene_Base
def map_window
return @map_window
end
def zone_window
return @zone_window
end
#--------------------------------------------------------------------------
# ● 开始处理时建立对象
#--------------------------------------------------------------------------
alias _start start
def start
@map_window = Map_Window.new
@zone_window = Zone_Window.new
_start
end
#--------------------------------------------------------------------------
# ● 释放时释放对象
#--------------------------------------------------------------------------
alias _terminate terminate
def terminate
@map_window.dispose
@zone_window.dispose
_terminate
end
#--------------------------------------------------------------------------
# ● 刷新时刷新对象
#--------------------------------------------------------------------------
alias _update update
def update
@zone_window.refresh
@map_window.refresh
_update
end
#--------------------------------------------------------------------------
# ● 标记为地区已改变(这个参数传递的很囧我承认)
#--------------------------------------------------------------------------
def zone_change
@map_window.zone_change
end
end
#==============================================================================
# ■ Zone_Window
#------------------------------------------------------------------------------
# 显示地区名的类
#=============================================================================
class Zone_Window<Window_Base
#--------------------------------------------------------------------------
# ● 新建对象初始化
#--------------------------------------------------------------------------
def initialize
super(0,0,50,50)
create_contents
self.opacity = 0
self.contents_opacity = 0
@time=0
self.contents.font.shadow = false
end
#--------------------------------------------------------------------------
# ● 直接显示
#--------------------------------------------------------------------------
def d_display
@direct=1
end
#--------------------------------------------------------------------------
# ● 得到地区名
#--------------------------------------------------------------------------
def zone(id=$game_map.map_id)
name=$data_areas[$game_player.area_id].name.split(/@/)[1] if $game_player.area_id.is_a?(Numeric)
if name==nil || name==""
name=$game_map.name[id].name.split(/@/)[1]
end
#~ p name
return name
end
#--------------------------------------------------------------------------
# ● 得到地区英文名
#--------------------------------------------------------------------------
def zonee(id=$game_map.map_id)
name=$game_map.name[id].name.split(/@/)[2]
if $game_player.area_id.is_a?(Numeric)
if $data_areas[$game_player.area_id].name.split(/@/)[1]!=nil &&
$data_areas[$game_player.area_id].name.split(/@/)[1]!=""
name=$data_areas[$game_player.area_id].name.split(/@/)[2]
end
end
name="" if name==nil
return name
end
#--------------------------------------------------------------------------
# ● 描绘中文名
#--------------------------------------------------------------------------
def drawtext(x)
self.contents.font.name=["华文中宋","STZhongsong","宋体","黑体"]
self.contents.font.size=36
self.contents.font.shadow=false
self.contents.font.color=Color.new(255,255,255)
self.contents.draw_text_f(x,0,self.contents.width,36,@text)
end
#--------------------------------------------------------------------------
# ● 描绘英文名
#--------------------------------------------------------------------------
def drawtexten(x)
self.contents.font.name=["Copperplate Gothic Light"]
self.contents.font.size=12
self.contents.font.shadow=false
self.contents.font.color=Color.new(255,255,255)
self.contents.draw_text_f(x,49,self.contents.width,12,@texten)
end
#--------------------------------------------------------------------------
# ● 描绘横线
#--------------------------------------------------------------------------
def drawline
self.contents.fill_rect(self.contents.width-5-@textw-1, 40, @textw+2, 5, Color.new(0,0,0,255))
self.contents.fill_rect(self.contents.width-5-@textw, 41, @textw, 3, Color.new(255,255,255,255))
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if (self.zone != $game_actors[T_m::ZONE_NUM].name && self.zone != "" && self.zone != nil)||@direct==1
$game_actors[T_m::ZONE_NUM].name=self.zone
$scene.zone_change
if ($game_switches[T_m::ZONE_W_S] == true)|| @direct==1
@text=self.zone
@texten=self.zonee
@[email protected]*36/3
@[email protected]*6
@textw=[@textl,@textenl].max+24
@l=@textw/12
self.x=T_m::VX_W-@textw-@textl-5-16
self.y=0
self.width=@textw+@textl+5+32
self.height=32+12+12+36
@time=T_m::Z_IN_TIME+T_m::Z_SHOW_TIME+T_m::Z_FADE_TIME
@direct=0
create_contents
end
end
if @time>T_m::Z_SHOW_TIME+T_m::Z_FADE_TIME
self.contents_opacity = 255*(T_m::Z_IN_TIME+T_m::Z_SHOW_TIME+T_m::Z_FADE_TIME-@time)/(T_m::Z_IN_TIME-1)
drawline
if @time%2==1
self.contents.clear
drawline
drawtext((self.contents.width-5-(@textw-@textl)/2-@textl)*(T_m::Z_IN_TIME+T_m::Z_SHOW_TIME+T_m::Z_FADE_TIME-@time)/(T_m::Z_IN_TIME-1))
drawtexten(self.contents.width-(5+(@textw-@textenl)/2+@textenl)*(T_m::Z_IN_TIME+T_m::Z_SHOW_TIME+T_m::Z_FADE_TIME-@time)/(T_m::Z_IN_TIME-1))
end
@time-=1
elsif @time>T_m::Z_FADE_TIME
@time-=1
elsif @time>0
self.contents_opacity = 255*(@time-1)/(T_m::Z_FADE_TIME-1)
if @time%2==1
self.contents.clear
drawline
drawtext(self.contents.width-(5+(@textw-@textl)/2+@textl)*(@time-1)/(T_m::Z_FADE_TIME-1))
drawtexten((self.contents.width-5-(@textw-@textenl)/2-@textenl)*(@time-1)/(T_m::Z_FADE_TIME-1))
self.contents.blur
end
@time-=1
else
self.opacity=0
self.contents_opacity=0
end
end
end#▼▼▼通用变量、方法、模块、类▼▼▼
#==============================================================================
# ■ (模块)T_m
#------------------------------------------------------------------------------
# 用来存储常用常量
#=============================================================================
module T_m
#-----------------------------------------------------------------------------
# ● 地名窗口常量
#-----------------------------------------------------------------------------
#▼地名窗口
WIDTH = 150 # 窗口宽度最小值
IN_TIME = 20 # 窗口出现时间
SHOW_TIME = 60 # 窗口显示时间
FADE_TIME = 30 # 窗口淡去时间
TEXT1_SIZE = 19 # 地图名,区域名的字体大小
TEXT2_SIZE = 13 # 地区名的字体大小
TEXT1_COLOR = Color.new(255,255,255) # 地图名,区域名的默认颜色
TEXT2_COLOR = Color.new(255,60,60) # 地区名的默认颜色
SKIN = "window" # 窗口皮肤的文件名
VX_H = 416 # VX窗口高度
VX_W = 544 # VX窗口宽度
ZONE_NUM =8 # 地区名占用角色名的编号
Map_W_S=1 # 控制是否显示的开关
#▼地区名窗口
Z_IN_TIME = 30 # 窗口出现时间
Z_SHOW_TIME = 70 # 窗口显示时间
Z_FADE_TIME = 30 # 窗口淡去时间
ZONE_W_S=2 # 控制是否显示开关
#▼计算
HEIGHT = TEXT1_SIZE + TEXT2_SIZE + 34 # 窗口高度
MWINDOW_Y = VX_H - HEIGHT - 16 # 窗口Y坐标
#----------------------------------------------------------------------------
# ● 路牌门牌NPC常量
#----------------------------------------------------------------------------
#▼路口窗口
RT_WIDTH=240 #窗口宽度的最小值
RT_Y=30 #窗口Y值
RT_INTIME=20 #窗口出现时间
RT_ONTIME=60 #窗口持续时间
RT_FADETIME=20 #窗口消失时间
RT_S=3 #控制开关
RT_TEXTSIZE=20 #字体大小
RT_TEXTCOLOR=Color.new(255,255,255) #字体颜色
#▼NPC窗口
NPC_ICON_TALK="talk" #「谈话」图标名
NPC_ICON_TRADE="trade" #「交易」图标名
NPC_ICON_CHECK="check" #「调查」图标名
NPC_NAME_SIZE=16 #「NPC」人名字号
NPC_S=4 #「NPC控制开关」编号
#▼门牌窗口
DOOR_NAME_SIZE=22 #门牌「名称」字号
DOOR_TYPE_SIZE =16 #门牌「类型」字号
DOOR_S=5 #「门牌」控制开关编号
#----------------------------------------------------------------------------
# ●其他
#----------------------------------------------------------------------------
def self.preview_dis
return @preview_dis
end
def self.preview_dis=(a)
return @preview_dis=a
end
@preview_dis=false
end
#----------------------------------------------------------------------------
# ● 方法:读取属性
#----------------------------------------------------------------------------
def readattr(str,section,ignore_caps = false)
str="" if str.class!=String
result=''
section.upcase! if ignore_caps
s = section.to_sym
temp = str.split(/=/)
temp.each{|i|i.strip!}
temp[0].upcase! if ignore_caps
temp[0]=" " if temp[0]==nil
if temp[0].to_sym==s
unless temp[1]==nil
result=temp[1]
end
end
return result
end
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
# 对Game_Map类的追加定义。
#=============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● 获取所在场景名称
#--------------------------------------------------------------------------
def name
load_data("Data/MapInfos.rvdata")
end
end
#==============================================================================
# ■ Game_Character
#------------------------------------------------------------------------------
# 判断当前人物所在区域id(by beside)。
#=============================================================================
class Game_Character
def area_id
for area in $data_areas.values
if in_area?(area)
return area.id
end
end
end
end
#==============================================================================
# ◎ GPRA_Bitmap
#------------------------------------------------------------------------------
# ◎ Bitmap功能加强
#------------------------------------------------------------------------------
# 制作者:绿梨子红苹果
# 个人主页:vbgm.9126.com
# E-Mail:[email protected]
# QQ:42378361
#==============================================================================
class Bitmap
# 影子字
def draw_text_s(x, y, width, height, str, align=0)
# 保存当前颜色
r=self.font.color.red
g=self.font.color.green
b=self.font.color.blue
# 颜色更改成黑色
self.font.color.set(0, 0, 0)
# 绘制影子
self.draw_text(x+2, y+2, width, height, str, align)
# 恢复原始字色
self.font.color.set(r,g,b)
# 绘制原来的字
self.draw_text(x, y, width, height, str, align)
end
# 描边字
def draw_text_f(x, y, width, height, str, align=0)
# 保存当前颜色
r=self.font.color.red
g=self.font.color.green
b=self.font.color.blue
# 颜色更改成黑色
self.font.color.set(0, 0, 0)
# 绘制边框
self.draw_text(x-1, y-1, width, height, str, align)
self.draw_text(x-1, y+1, width, height, str, align)
self.draw_text(x+1, y-1, width, height, str, align)
self.draw_text(x+1, y+1, width, height, str, align)
self.draw_text(x, y-1, width, height, str, align)
self.draw_text(x, y+1, width, height, str, align)
self.draw_text(x-1, y, width, height, str, align)
self.draw_text(x+1, y, width, height, str, align)
# 恢复原始字色
self.font.color.set(r,g,b)
# 绘制原来的字
self.draw_text(x, y, width, height, str, align)
end
end
跟随脚本
#==============================================================================
# ■ 人物跟随
#------------------------------------------------------------------------------
#
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#
# 作者:fukuyama
#
# 移植:ONEWateR
#
#==============================================================================
module Train_Actor
#是否使用停止跟随的方法,也就是说,这里false改为true的时候,如果TRANSPARENT_SWITCHES_INDEX
#开关打开,跟随的人物就消失了(其实只是变成透明而已)
TRANSPARENT_SWITCH = true
TRANSPARENT_SWITCHES_INDEX = 1
#举例:第一个为true,第二个为20,则打开20号开关,后面的人都没了。
#跟随人数的最大数目,可以更改为2、3什么的。
TRAIN_ACTOR_SIZE_MAX = 4
# 定数
DOWN_LEFT = 1
DOWN_RIGHT = 3
UP_LEFT = 7
UP_RIGHT = 9
JUMP = 5
class Game_Party_Actor < Game_Character
def initialize
super()
@through = true
end
def setup(actor)
if actor != nil
@character_index = actor.character_index
@character_name = actor.character_name
@priority_type = 1
else
@character_name = ""
@character_index = 0
@priority_type = 1
end
# 不透明度と合成方法を初期化
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# ● 下に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
# 下を向く
if turn_enabled
turn_down
end
# 通行可能な場合
if new_passable?(@x, @y, Input::DOWN)
# 下を向く
turn_down
# 座標を更新
@y += 1
end
end
#--------------------------------------------------------------------------
# ● 左に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
# 左を向く
if turn_enabled
turn_left
end
# 通行可能な場合
if new_passable?(@x, @y, Input::LEFT)
# 左を向く
turn_left
# 座標を更新
@x -= 1
end
end
#--------------------------------------------------------------------------
# ● 右に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
# 右を向く
if turn_enabled
turn_right
end
# 通行可能な場合
if new_passable?(@x, @y, Input::RIGHT)
# 右を向く
turn_right
# 座標を更新
@x += 1
end
end
#--------------------------------------------------------------------------
# ● 上に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
# 上を向く
if turn_enabled
turn_up
end
# 通行可能な場合
if new_passable?(@x, @y, Input::UP)
# 上を向く
turn_up
# 座標を更新
@y -= 1
end
end
#--------------------------------------------------------------------------
# ● 左下に移動
#--------------------------------------------------------------------------
def move_lower_left
# 向き固定でない場合
unless @direction_fix
# 右向きだった場合は左を、上向きだった場合は下を向く
@direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
end
# 下→左、左→下 のどちらかのコースが通行可能な場合
if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::LEFT)) or
(new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::DOWN))
# 座標を更新
@x -= 1
@y += 1
end
end
#--------------------------------------------------------------------------
# ● 右下に移動
#--------------------------------------------------------------------------
def move_lower_right
# 向き固定でない場合
unless @direction_fix
# 左向きだった場合は右を、上向きだった場合は下を向く
@direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
end
# 下→右、右→下 のどちらかのコースが通行可能な場合
if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::RIGHT)) or
(new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::DOWN))
# 座標を更新
@x += 1
@y += 1
end
end
#--------------------------------------------------------------------------
# ● 左上に移動
#--------------------------------------------------------------------------
def move_upper_left
# 向き固定でない場合
unless @direction_fix
# 右向きだった場合は左を、下向きだった場合は上を向く
@direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
end
# 上→左、左→上 のどちらかのコースが通行可能な場合
if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::LEFT)) or
(new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::UP))
# 座標を更新
@x -= 1
@y -= 1
end
end
#--------------------------------------------------------------------------
# ● 右上に移動
#--------------------------------------------------------------------------
def move_upper_right
# 向き固定でない場合
unless @direction_fix
# 左向きだった場合は右を、下向きだった場合は上を向く
@direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
end
# 上→右、右→上 のどちらかのコースが通行可能な場合
if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::RIGHT)) or
(new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::UP))
# 座標を更新
@x += 1
@y -= 1
end
end
attr_writer :move_speed
attr_writer :step_anime
end
module Spriteset_Map_Module
def setup_actor_character_sprites?
return @setup_actor_character_sprites_flag != nil
end
def setup_actor_character_sprites(characters)
if !setup_actor_character_sprites?
index_game_player = 0
@character_sprites.each_index do |i|
if @character_sprites.character.instance_of?(Game_Player)
index_game_player = i
break
end
end
for character in characters.reverse
@character_sprites.unshift(
Sprite_Character.new(@viewport1, character)
)
end
@setup_actor_character_sprites_flag = true
end
end
end
module Scene_Map_Module
def setup_actor_character_sprites(characters)
@spriteset.setup_actor_character_sprites(characters)
end
end
module Game_Party_Module
def set_transparent_actors(transparent)
@transparent = transparent
end
def setup_actor_character_sprites
if @characters == nil
@characters = []
for i in 1 ... TRAIN_ACTOR_SIZE_MAX
@characters.push(Game_Party_Actor.new)
end
end
for i in 1 ... TRAIN_ACTOR_SIZE_MAX
@characters[i - 1].setup($game_party.members)
end
if $scene.class.method_defined?('setup_actor_character_sprites')
$scene.setup_actor_character_sprites(@characters)
end
end
def update_party_actors
setup_actor_character_sprites
transparent = $game_player.transparent
if transparent == false
if TRANSPARENT_SWITCH
transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
end
end
for character in @characters
character.transparent = transparent
if $game_player.dash?
character.move_speed = $game_player.move_speed*1.25
else
character.move_speed = $game_player.move_speed
end
character.step_anime = $game_player.step_anime
character.update
end
end
def moveto_party_actors( x, y )
setup_actor_character_sprites
for character in @characters
character.moveto( x, y )
end
if @move_list == nil
@move_list = []
end
move_list_setup
end
def move_party_actors
if @move_list == nil
@move_list = []
move_list_setup
end
@move_list.each_index do |i|
if @characters != nil
case @move_list.type
when Input::DOWN
@characters.move_down(@move_list.args[0])
when Input::LEFT
@characters.move_left(@move_list.args[0])
when Input::RIGHT
@characters.move_right(@move_list.args[0])
when Input::UP
@characters.move_up(@move_list.args[0])
when DOWN_LEFT
@characters.move_lower_left
when DOWN_RIGHT
@characters.move_lower_right
when UP_LEFT
@characters.move_upper_left
when UP_RIGHT
@characters.move_upper_right
when JUMP
@characters.jump(@move_list.args[0],@move_list.args[1])
end
end
end
end
class Move_List_Element
def initialize(type,args)
@type = type
@args = args
end
def type() return @type end
def args() return @args end
end
def move_list_setup
for i in 0 .. TRAIN_ACTOR_SIZE_MAX
@move_list = nil
end
end
def add_move_list(type,*args)
@move_list.unshift(Move_List_Element.new(type,args)).pop
end
def move_down_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::DOWN,turn_enabled)
end
def move_left_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::LEFT,turn_enabled)
end
def move_right_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::RIGHT,turn_enabled)
end
def move_up_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::UP,turn_enabled)
end
def move_lower_left_party_actors
move_party_actors
add_move_list(DOWN_LEFT)
end
def move_lower_right_party_actors
move_party_actors
add_move_list(DOWN_RIGHT)
end
def move_upper_left_party_actors
move_party_actors
add_move_list(UP_LEFT)
end
def move_upper_right_party_actors
move_party_actors
add_move_list(UP_RIGHT)
end
def jump_party_actors(x_plus, y_plus)
move_party_actors
add_move_list(JUMP,x_plus, y_plus)
end
end
module Game_Player_Module
def update
$game_party.update_party_actors
super
end
def moveto( x, y )
$game_party.moveto_party_actors( x, y )
super( x, y )
end
def move_down(turn_enabled = true)
if new_passable?(@x, @y, Input::DOWN)
$game_party.move_down_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_left(turn_enabled = true)
if new_passable?(@x, @y, Input::LEFT)
$game_party.move_left_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_right(turn_enabled = true)
if new_passable?(@x, @y, Input::RIGHT)
$game_party.move_right_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_up(turn_enabled = true)
if new_passable?(@x, @y, Input::UP)
$game_party.move_up_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_lower_left
# 下→左、左→下 のどちらかのコースが通行可能な場合
if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::LEFT)) or
(new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::DOWN))
$game_party.move_lower_left_party_actors
end
super
end
def move_lower_right
# 下→右、右→下 のどちらかのコースが通行可能な場合
if (new_passable?(@x, @y, Input::DOWN) and new_passable?(@x, @y + 1, Input::RIGHT)) or
(new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::DOWN))
$game_party.move_lower_right_party_actors
end
super
end
def move_upper_left
# 上→左、左→上 のどちらかのコースが通行可能な場合
if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::LEFT)) or
(new_passable?(@x, @y, Input::LEFT) and new_passable?(@x - 1, @y, Input::UP))
$game_party.move_upper_left_party_actors
end
super
end
def move_upper_right
# 上→右、右→上 のどちらかのコースが通行可能な場合
if (new_passable?(@x, @y, Input::UP) and new_passable?(@x, @y - 1, Input::RIGHT)) or
(new_passable?(@x, @y, Input::RIGHT) and new_passable?(@x + 1, @y, Input::UP))
$game_party.move_upper_right_party_actors
end
super
end
def jump(x_plus, y_plus)
# 新しい座標を計算
new_x = @x + x_plus
new_y = @y + y_plus
# 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
if (x_plus == 0 and y_plus == 0) or new_passable?(new_x, new_y, 0)
$game_party.jump_party_actors(x_plus, y_plus)
end
super(x_plus, y_plus)
end
attr_accessor :move_speed
attr_accessor :step_anime
end
end # module Train_Actor
class Game_Party
include Train_Actor::Game_Party_Module
end
class Game_Player
include Train_Actor::Game_Player_Module
end
class Spriteset_Map
include Train_Actor::Spriteset_Map_Module
end
class Scene_Map
include Train_Actor::Scene_Map_Module
end
class Game_Character
def new_passable?(x, y, d)
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
unless $game_map.valid?(new_x, new_y)
return false
end
x = $game_map.round_x(x) # 横方向循环修正
y = $game_map.round_y(y) # 纵方向循环修正
return false unless $game_map.valid?(x, y) # 地图外?
return true if @through or debug_through? # 穿越 ON?
return false unless map_passable?(new_x, new_y) # 地图不能通行?
return false if collide_with_characters?(new_x, new_y) # 与角色冲突?
return true # 可以通行
end
end
这三个脚本,当用了npc名脚本时其余两个都没法显示了,请问该怎么办???有没有办法通过改脚本兼容???(注:地名脚本需要图片xxx,懒得放上去) |
|