Project1
标题: VX NPC名字显示问题 [打印本页]
作者: pr84201783 时间: 2012-1-8 10:29
标题: VX NPC名字显示问题
本帖最后由 各种压力的猫君 于 2012-1-15 04:33 编辑
请问一下 NPC显示名字 如何把主角头上的名字给去掉? 只显示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
复制代码