#============================================================================== # 本脚本来自[url]www.66rpg.com[/url],转载、使用请保留此信息 #============================================================================== # 作者:柳柳 # # 使用方法:插入到main前即可,之后就会显示每个事件的名字。 # 不想显示名字的NPC直接把名字设置为一个空格就行了。 # # 附加功能:名字颜色区分:比如一个NPC的名字是 柳柳,2 就会用2号颜色(红色)显示 # # 修改NPC名的方法:$game_map.events[事件ID编号].name = # 比如某个宝箱,原名宝箱,打开后名为“打开的宝箱”,则 # $game_map.events[@event_id].name = "打开的宝箱" 或者 # $game_map.events[2].name = "打开的宝箱" (假设宝箱是2号事件) # # 修改颜色定义:70-88行,131-149行,自己随便改。 # # 给主角带上名字:192行,改 "" 为 "主角" 或者 $game_party.actors[0].name 即可 # # 是否显示姓名的开关:157行,开头的井号去掉。则以后39号开关打开的时候才会显示姓名 # #============================================================================== # ■ Game_Event #------------------------------------------------------------------------------ # 处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能 # 在 Game_Map 类的内部使用。 #============================================================================== class Game_Event < Game_Character #—————————————————————————————————————— # 用来返回名称 #—————————————————————————————————————— def name return @event.name end def name=(newname) @event.name = newname end end #============================================================================== # ■ Sprite_Character #------------------------------------------------------------------------------ # 角色显示用脚本。监视 Game_Character 类的实例、 # 自动变化脚本状态。 #============================================================================== class Sprite_Character < RPG::Sprite #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_accessor :character # 角色 #-------------------------------------------------------------------------- # ● 初始化对像 # viewport : 查看端口 # character : 角色 (Game_Character) #-------------------------------------------------------------------------- def initialize(viewport, character = nil) name = character.name super(viewport) @character = character @namesprite = Sprite.new @namesprite.bitmap = Bitmap.new(160, 48) @namesprite.bitmap.font.name = "黑体" @namesprite.bitmap.font.size = 16 @namesprite.bitmap.font.color.set(255, 255, 255) @evname = name @evname_split = name.split(/,/)[0] if name[0, 2]=="EV" @evname_split = " " end if name.split(/,/)[1] != nil case name.split(/,/)[1] when "0" @namesprite.bitmap.font.color.set(255, 255, 255) when "1" @namesprite.bitmap.font.color.set(128, 128, 255) when "2" @namesprite.bitmap.font.color.set(255, 128, 128) when "3" @namesprite.bitmap.font.color.set(128, 255, 128) when "4" @namesprite.bitmap.font.color.set(128, 255, 255) when "5" @namesprite.bitmap.font.color.set(255, 128, 255) when "6" @namesprite.bitmap.font.color.set(255, 255, 128) when "7" @namesprite.bitmap.font.color.set(192, 192, 192) when "8" @namesprite.bitmap.font.color.set(200, 19, 106) else @namesprite.bitmap.font.color.set(255, 255, 255) end end if @evname_split != "" and @evname_split != nil @namesprite.bitmap.draw_text(0, 0, 160, 36, @evname_split, 1) end 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 为有效值的情况下 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 # 元件 ID 为无效值的情况下 else self.bitmap = RPG::Cache.character(@character.character_name, @character.character_hue) @cw = bitmap.width / 4 @ch = bitmap.height / 4 self.ox = @cw / 2 self.oy = @ch end end if @evname != @character.name @namesprite.bitmap.clear @evname = @character.name @evname_split = @character.name.split(/,/)[0] if @character.name.split(/,/)[1] != nil case @character.name.split(/,/)[1] when "0" @namesprite.bitmap.font.color.set(255, 255, 255) when "1" @namesprite.bitmap.font.color.set(128, 128, 255) when "2" @namesprite.bitmap.font.color.set(255, 128, 128) when "3" @namesprite.bitmap.font.color.set(128, 255, 128) when "4" @namesprite.bitmap.font.color.set(128, 255, 255) when "5" @namesprite.bitmap.font.color.set(255, 128, 255) when "6" @namesprite.bitmap.font.color.set(255, 255, 128) when "7" @namesprite.bitmap.font.color.set(192, 192, 192) when "8" @namesprite.bitmap.font.color.set(200, 19, 106) else @namesprite.bitmap.font.color.set(255, 255, 255) end end if @evname_split != "" and @evname_split != nil @namesprite.bitmap.draw_text(0, 0, 160, 36, @evname_split, 1) end end @namesprite.x = self.x-80 @namesprite.y = self.y-self.oy-24 #@namesprite.visible = $game_switches[39] # 设置可视状态 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.screen_z(@ch) # 设置不透明度、合成方式、茂密 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 #============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ # 处理主角的类。事件启动的判定、以及地图的滚动等功能。 # 本类的实例请参考 $game_player。 #============================================================================== class Game_Player < Game_Character def name return "" end end #============================================================================== # 本脚本来自[url]www.66rpg.com[/url],转载、使用请保留此信息 #==============================================================================
未命名.png (53.91 KB, 下载次数: 25)
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |